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.

White Belt

Re: Some useful Regex statements

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.

 

Announcements
We want your feedback to improve the Dojo Community! If you are coming to the Dojo Award Ceremony next week Click here to learn more!