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

RanjithJose
RanjithJose Dataiku DSS Core Concepts, Registered Posts: 13 ✭✭✭✭

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

  • fchataigner2
    fchataigner2 Dataiker Posts: 355 Dataiker
    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

Setup Info
    Tags
      Help me…