cancel
Showing results for 
Search instead for 
Did you mean: 

Replace dots with space using Replace

Former Member
0 Kudos

Hi,

I have a field which has 008.2009.

I need to extract the contents before DOT character or just ignore the contents after DOT character.

Used replace string function but just replaces the DOT character with space.

Without UDF, let me know whether it is possible using std functions.

Regards

Krish

Accepted Solutions (1)

Accepted Solutions (1)

former_member200962
Active Contributor
0 Kudos

Is your requirement just to get 008 in the target field?

If yes then this can be achieved using the IndexOf function and then based on the value returned by the IndeOf function do a substring and have only the part before dot.

If above is the requirement then it can be easily achieved using a UDF....a very simple UDF.

Update:

I dont think standard functions will help.....the substring function will need the ending location of the string (in your case 8)....this is actually passed as length....hence UDF is required....any specific for avoiding UDF?

Regards,

Abhishek.

Edited by: abhishek salvi on Sep 23, 2009 5:00 PM

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

This is not possible without UDF, you need to use simple udf code for this.

Parameter = String.


char[] temp1 = new char[inputfield.length+1];
char[] temp = new char[inputfield.length+1];

temp = inputfield.toCharArray();

for(int i=0; temp.length()>i;i++)
{
  temp1<i> = temp<i>;
   if(temp<i>.equals('.'))
           break;

   result.addValue(String.valueof(tem1p<i>));
}

Thanks

Swarup

Thanks

swarup

Former Member
0 Kudos

create a UDF with one argument a


return a.substring(0, a.indexOf("."));

jyothi_anagani
Active Contributor
0 Kudos

Hi,

Map Like this..

input---->UDF---->Output

UDF Code is

return a.substring(0,a.indexOf('.'));

Only one line code...

Thanks.

Former Member
0 Kudos

it is not possible with the standard function you have to use UDF

Former Member
0 Kudos

Hi Krish,

If the dot always appears after three digits (numbers) then you can use the substring function.

Using substring you can get numbers before dot (008).

UDF is not required to achieve this if the DOT always appears after three digits.

Let me know what output string do you exactly need?

Regards,

Gautam Purohit

Edited by: Gautam Purohit on Sep 23, 2009 1:32 PM