Regular Expression Replace double spaces in a string with one space.
Hi,
I have a string 'Ranjith Jose' in column 'Name', which has double space between first and last name. I have used Replace prepare recipe.
Matching Mode: Regular Expression
Normalization Mode: Exact
Replacements
\s+ --> No Value (I need to keep one space instead of 'No Value'.)
Please assist.
Thanks,
Ranjith Jose.
Best Answer
-
Hi,
the Find&Replace step used to trim and ignore whitespace on replacements until quite recently, so if you aren't on a v9.0.3, it's probably the expected behavior.
You should use a "Formula" step, and use replaceChars() or replace(), like
strval("Name").replaceChars(" ", " ")
or
strval("Name").replace(/\s+/, " ")
Answers
-
Thanks fchataigner2!
It worked! Appreciate your help
-
how to apply this formula for all columns.
-
@fchataigner2
how to apply this formula for all columns.