Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Find and Replace Multiple Characters

I have a field where I want to find and replace a multiple letters within the data of a field.  See example below.

11111A

11111B

11111C

I need to replace A, B and C.  A should be replaced with 1, B with 2 and C with 3 when present.  I know if I just had one character, I could just use the REPLACE function.  But in this case I have multiple different characters that could be found within the field.  How do I go about search and replacing multiple characters with the data of a field. Hopefully, that makes sense.

Thank you in advanced for your assistance.

Brian

3 Replies
Anonymous
Not applicable
Author

Could you nest the Replace() 's :

=replace ( replace ( replace ( '11111A' ,'A' ,'1' ) , 'B' , 2 ) , 'C' , '3' )

=replace ( replace ( replace ( '11111B' ,'A' ,'1' ) , 'B' , 2 ) , 'C' , '3' )

=replace ( replace ( replace ( '11111C' ,'A' ,'1' ) , 'B' , 2 ) , 'C' , '3' )

MarcoWedel

Maybe you could use mapsubstring.

Regards

Marco

maxgro
MVP
MVP

Map:

mapping load * inline [

from, to

A,1

B,2

C,3

];

MyTable:

load field, MapSubString('Map', field) as newfield inline [

field

11111A

11111B

11111C

ABC

];