Some useful Regex statements

ToDo:

Use an Edit Data --> Replace Text action in the workflow.

Select Regex option and replace by empty string.

You can also replace the match with any string you require.

 

Get Handles:

(^|\s|[^@\w])+[^@\s]+

Example: Hi @Something how are @you doing David.

Result: @Something @you

 

Get Hastags:

(^|\s|[^#\w])+[^#\s]+ 

Example: Hi #Something how are #you doing David.

Result: #Something #you

 

 

Remove Handles:

(?=(@\w+\b))

Example: Hi @Something how are @you doing David.

Result: Hi how are doing David.

 

Remove Hashtags:

(?=(#\w+\b))

 

Example: Hi #Something how are #you doing David.

Result: Hi how are doing David

 

Get a word or phrase:

\b(?!cat\b)\w+

Example: This cat is beautiful!!

Result: cat

 

Except a word or phrase:

\b(?=cat\b)\w+

Example: This cat is beautiful!!

Result: This is beautiful!!

 

Get Character(s):

Get 1st  four characters (including space)

(?<=.{4}).+ 

Example: This cat is beautiful!!

Result: This

 

Get last four characters (including space)

.+(?=.{4})

Example: This cat is beautiful!!

Result: ul!!

 

** I will append more Regex scenario as I go through them. Please feel free to add or comment on the scenarios you go through more frequently and I will try to append it asap.

Tagged:

Comments

  • Select all the characters before a character or word:

    .*are)

    Example: Hi #Something how are #you doing David.

    Result: Hi #Something how

     

    Select all the characters after a character or word:

    are.*

    Example: Hi #Something how are #you doing David.

    Result: #you doing David.

     

  • Domofied
    Domofied Contributor

    Hi NFSharma,

    Thanks for sharing these formulas.

    Do you have anything for the last 2 formulas for all characters before and after, for a multi-line field ?


    I've tested this out on Regex101 website

    ^(?!Numbers:).*

    and it works, removing all text except for the bold text below, but does not work in Domo,


    ______________________________ OVERVIEW ______________________________


    Booking Error: DangerousGoodContact 1.67.10 - Unable to add an item that has dangerous goods information without adding a dangerous goods contact name and phone number.


    Carrier: Transport Express - Parcel

    Account Number: TRS74844

    Site: Solid Items - VIC

    45 Yellow Court, Bentleigh East VIC 3168

    Phone: -

    User: Sales

    Email: sales@soliditems.com.au

    Phone: -


    Consignments: 5A

    Numbers: SOSO101951 SOSO101954 SOSO101952 SOSO101953 SOSO101955

    Largest Dimensions: 26x49x32 cm

    Total Weight: 49.0 kg

    Total Cubic: 0.1623 m3

    Total Items: 5

    Dangerous Goods: YES

  • Hi @Domofied

    If you have Magic ETL 2.0 you can use the regex_replace function to pass in processing flags - this isn't possible with the ETL 1.0 Replace Text tile. By default regex101 as the g (global) and m (multiline) flags enabled whereas Domo does not. Passing in the 'm' as the third parameter should resolve your issue.

    REGEXP_REPLACE(`note`, '^(?!Numbers:).*', '$1', 'm')
    


    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Domofied
    Domofied Contributor

    Hi Grant,

    That makes sense ! Hahahahaa 😂

    I'm currently working with ETL v1.0 so would there be any possible work arounds to handle multi-lines ?


    Cheers!

  • Hi @Domofied

    You might be able to do this as a calculated field in a Dataset View but because you're on ETL 1.0 you wouldn't be able to use it as an input into your dataflow. It'd have to be your last step before you visualize your data.

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**