I’m having some trouble with a regular expression. I need to replace only a part of a cell, the problem is that can be writen in differents ways. Example:
SNOOPY THE DOG
SNOPY THE DOG
SNOOPY DOG
SNOOP DOGG
I need to keep the word “DOG” but also have to modify the “SNOOPY” variables. I tryed with a string manipulation and this regex:
regexReplace($FAMILYFRIENDLY$, “SN.*”, “SNOOPY”)
Thanks for reading and hope to find a solution for this!
Hi @Tripaflaca , it would help if you could show us what the expected results of the given sample data would be.
So far, you have only showed us what you tried and it’s not giving the expected results, so we have no idea what the expected results you are looking for.
The lenght of the word “SNOOPY” in the first column can change, people who charge the information sometimes miss or add a letter, thats why i need a regex to include the most types of variations. Then I will check all the base and fix those cases where the regex couldnt fix the error.
You could use the cell splitter node or Regex to divide this into 2 columns. 1 with the first work and a second with the remaining string. Then you can do fuzzy match on the first word and then re-combine the changes with the second half of the string.
Hi @Tripaflaca , using your regex example as you have it, it will try replacing the entire string beginning with “SN” with SNOOPY, irrespective of word boundaries.
What this does is tell string manipulation to find any occurrence of SN after a “word boundary”, and then matching all letters up to the first next word boundary. The ? quantifier tells it to find the minimal matches to meet this criteria. This means it matches only up to the first word boundary, and not the entire string.
The \\ are required in String Manipulation instead of just a single \ because of the way the parsing of the string works.
Thanks all for answering. The solution for my problem was given for @takbb but i also found interesting the replay of @iCFO , I will use that solution for other cell i got that has lots of words and maybe a regex for that would be difficult.