Quantcast
Channel: Topliners : All Content - All Communities
Viewing all articles
Browse latest Browse all 2909

String Manipulation-Regex Code-Find where two words are in a string and then replace with one word

$
0
0

I'm currently trying to use the String Manipulation cloud component to look through a multi-select entry and identify where within the value there are two particular words and then replace with just one replacement word.

 

Example:

Original Value - ElectricBlue,Red,RoyalBlue

Desired Value - Red,Blue

 

Looking through existing regex code a colleague and I were able to find the following code that could successfully find where two words are near each other in a string: \bword1\W+(?:\w+\W+){1,6}?word2\b

 

We now need help writing the replacement code, if this is even possible. As you can see from the example above, we need the other original values in the replacement, along with the new replacement word for where the two other words once were.  Any suggestions?


Viewing all articles
Browse latest Browse all 2909

Trending Articles