Some useful Regex statements

Reply
White Belt

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.

Announcements
Win free lodging at Domopalooza! We want to hear your Domo story, enter our Dojo contest and win up to four nights lodging at Domopalooza. Click here!