The Dataiku Frontrunner Awards have launched to recognize your achievements! SUBMIT YOUR ENTRY

Regular Expression Replace double spaces in a string with one space.

RanjithJose
Level 1
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.

 

0 Kudos
2 Replies
fchataigner2
Dataiker
Dataiker

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+/, " ")

RanjithJose
Level 1
Author

Thanks fchataigner2! 

It worked! Appreciate your help 🙂

0 Kudos
A banner prompting to get Dataiku DSS
Public