Link to home
Start Free TrialLog in
Avatar of Carl3003
Carl3003

asked on

using regex to replace multiple strings at once ?

To replace multiple strings , i use the expression Regex("asdf sdfd sdfd",str1, someString) mulptiple times like
Regex("asdf sdfd sdfd",str2, someString)
Regex("asdf sdfd sdfd",str3, someString)
Regex("asdf sdfd sdfd",str4, someString)
I want to find a way to combine all these statements into just one..like this one
Regex("asdf sdfd sdfd", any of (str1, str2, str3, str4) , someString)

in other words to replace any occurrence of str1, str2, str3....
Thanks
SOLUTION
Avatar of Yurich
Yurich
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can call Replace with a MatchEvaluator delegate. The delegate will be called on every match and you can decide how you want to replace the matched string (or if you want to store it somewhere else).