Hi All,
I have a char field (length is 8) where I receive values like below,
88@b800
900#@12
123&c99 etc....
I need to replace the special characters & characters in it with Zero,
My output should be as below,
8800800
9000012
1230099
Can you pls let me know how we can accomplish this in Parallel jobs.
Any help would be highly appreciated.
Thanks in advance,
Freddie.
Replace Special Characters in a String
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 79
- Joined: Thu Mar 22, 2007 4:58 pm
- Location: USA
I would expect that you would handle that in a Transformer stage. Depending on what is easier, you could check for valid numbers or search for 'special characters'.
I'm not sure what your definition of a special character is for this derivation. From the example, it looks like anything that is not a Decimal digit (0..9) is a special character.
If that is the case, it may be easier to check for your numbers rather than check for special characters.
I'm not sure what your definition of a special character is for this derivation. From the example, it looks like anything that is not a Decimal digit (0..9) is a special character.
If that is the case, it may be easier to check for your numbers rather than check for special characters.
Jack Thornton
----------------
Spectacular achievement is always preceded by spectacular preparation - Robert H. Schuller
----------------
Spectacular achievement is always preceded by spectacular preparation - Robert H. Schuller
Hi Freddie,
I couldn't think anything straight for your problem.Bu tI have done something like this in one of my job sometime back.
I am explaining you what i had done
FIELD_A(length 3)-->sample data
1#4
&87
6*@
Requirement-> replace the special characters with zero(same as yours)
I have done it in transformer
i have used three stage variables for extracting the three characters
stage_var1==> FIELD_A[1,1],
stage_var2==> FIELD_A[2,1],
Stage_var3==>FIELD_A[3,1]
then 3 stage varaibels
Stage_var4==> if num(stage_var1)=1 then 'stage_var1' else '0'
Stage_var5==> if num(stage_var2)=1 then 'stage_var2' else '0'
Stage_var6==> if num(stage_var3)=1 then 'stage_var3' else '0'
finally
Stage_var4:Stage_var5:Stage_var6
You can reduce the number of stage variables, by clubbing them like
you can follow the same for your 8 characters
I belive this is kind of crude but there might be someother easier way to achive this.but i don't know whereas DS gurus can enlight us
Regards,
Raja R P
I couldn't think anything straight for your problem.Bu tI have done something like this in one of my job sometime back.
I am explaining you what i had done
FIELD_A(length 3)-->sample data
1#4
&87
6*@
Requirement-> replace the special characters with zero(same as yours)
I have done it in transformer
i have used three stage variables for extracting the three characters
stage_var1==> FIELD_A[1,1],
stage_var2==> FIELD_A[2,1],
Stage_var3==>FIELD_A[3,1]
then 3 stage varaibels
Stage_var4==> if num(stage_var1)=1 then 'stage_var1' else '0'
Stage_var5==> if num(stage_var2)=1 then 'stage_var2' else '0'
Stage_var6==> if num(stage_var3)=1 then 'stage_var3' else '0'
finally
Stage_var4:Stage_var5:Stage_var6
You can reduce the number of stage variables, by clubbing them like
Code: Select all
if
num(FIELD_A[1,1])=1 then FIELD_A[1,1] else '0'
I belive this is kind of crude but there might be someother easier way to achive this.but i don't know whereas DS gurus can enlight us
Regards,
Raja R P
Use Convert function. Collect All special symbols, characters specify at from list and add same number of zeros at to list.
Convert(%fromlist%,%tolist%,Inputfield)
The below example is based on your data.
Convert('&@#abcdefghijklmnopqrstuvwxyz','00000000000000000000000000000',Inputfield)
Convert(%fromlist%,%tolist%,Inputfield)
The below example is based on your data.
Convert('&@#abcdefghijklmnopqrstuvwxyz','00000000000000000000000000000',Inputfield)
Cheers
Ravi K
Ravi K
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
There's no sense of "special" characters here. You want to keep the numeric characters and convert all non-numeric characters to zero.
Code: Select all
svNonNumerics <== Convert("0123456789","",InLink.TheString)
Convert(svNonNumerics,Str("0",Len(svNonNumerics)),InLink.TheString)
Last edited by ray.wurlod on Wed Dec 29, 2010 3:50 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 47
- Joined: Tue Feb 23, 2010 12:16 am
- Location: CHENNAI
Re: Replace Special Characters in a String
Hi
In Server some functions are there like mca, ....
In Parallel you have to write routine
write server routine and call to this parallel job it will helps
Thanks,
Manoj
In Server some functions are there like mca, ....
In Parallel you have to write routine
write server routine and call to this parallel job it will helps
Thanks,
Manoj