Extracting WORDS in Datameer

2 followers
0
Avatar

Hi,

How to extract words from a column ?

If my cell contains:-

Ex: She went to the park in London.

Search word : park

Result should be : the park

I want the result to include one word which appears before the string too...which 'is the' in the above case.

Thanks 

 

 

 

 

Reeta

3 comments

  • Avatar
    Alan Mark

    Hi Reeta,

    REGEXTRACT(#Column;"[a-zA-Z]*\\spark")

    REGEX: [a-zA-Z]*\spark

    Explanation

    [a-zA-Z] - Finds any upper or lower case character in the alphabet

    * - quantifier, any number of the above a-z/A-Z characters allowing an entire word match

    \s - one whitespace character

    park - find literal word park

    So basically, this regex finds the word park, then grabs the space in front of it and the word in front of it.

    I developed this regex using the regex101.com website.  It's a great tool for learning how to build regex's yourself.

    Alan

    0
  • Avatar
    Reeta

    Hi Alan,

    Thanks for the response.

    But it doesnt seem to work on datameer , I tried it and it gives a synatx error.

    0
  • Avatar
    Alan Mark

    Hi Reeta,

    If you use the formula editor this should work.

    If you're going to paste directly into the formula bar, use \\s instead of just \s. 

     

    The formula editor will automatically escape any special characters for you, such as backslash in this case.  

    0
Please sign in to leave a comment.