Search code examples
regexazureazure-data-factory

Regular expression in ADF


How to split the string based on white spaces in DataFlow expression builder in ADF pipeline. A string can have 1 or more white spaces.

Eg: 

I used split(name,’ ‘) : Thiswill split the word based on single space.Some times it can have more than 1 space. How to handle that?

Joe Smith(1 white space)
Joel  Smith(2 white space)
Joplin   Smith(3 white space)

Solution

  • This is my sample data with spaces.

    enter image description here

    column
    Steve Smith C      S  K
    Rakesh Govindula     Laddu
    Chinna R     C      B
    

    Use the below expression to get the words array without empty strings.

    filter(split(column,' '),#item!='')

    enter image description here

    As there is no join function in dataflow expressions, to get the string of words with one space, use below expression from this SO Answer by @Jarred Jobe.

    dropLeft(toString(reduce(filter(split(column,' '),#item!=''), '', #acc +  ' '  + #item, #result)), 0)
    

    enter image description here