cancel
Showing results for 
Search instead for 
Did you mean: 

Replacing multiple strings by the same value

former_member318041
Participant
0 Kudos
1,035

Hi all,
I am working with "SAP BusinessObjects Business Intelligence 4.2" and have the following problem. I need to replace certain strings within a variable by another string.
E.g. if the strings is "abc", "odo" or "xyz", it needs to be replaced by ths string "TEST".

If the content of my variable is "ddddddabcddddd", it should result in "ddddddTESTddddd".
If the content of my variable is "ddddddododdddd", it should also result in "ddddddTESTddddd".
If the content of my variable is "ddddddxyzddddd", it should also result in "ddddddTESTddddd".
...
It is easy to do this, if there is just one string to be replaced, but in my case there are about 15 strings that need to be replaced in the described way.

Any ideas?
View Entire Topic
former_member199945
Active Contributor
0 Kudos

Hi,

Create another variable using inlist operator..

v1= if([string]inlist("abc";"odo";"xyz")) then "test" elseif([string] inlist("def";"ghi") )then "test1" else [string]

Thanks

former_member318041
Participant
0 Kudos

Hi,

thank you for the quick answer, but this is not exactly what I need ...

I want to replace a string within another string and not the complete string!
"ddddddabcddddd" --> "ddddddTESTddddd"

This solution works when you need to replace complete strings, but not parts of a string.
Any ideas?

BR,
Henning

former_member199945
Active Contributor
0 Kudos

Hi,

An answer was provided by Ayman Salem by defining variable using match and replace functions . Try the same formula.

Thanks