Extract Last word

Hi Team,

Want to extract only the word Offer from the below line ignoring question mark

Got a Job Offer ?

Hi @Honda

Use the below regular expression, it will extract the last word before the question mark.

\w+(?=\s+\?)

- Assign -> Input = "Got a Job Offer ?"
- Assign -> Output = System.Text.RegularExpressions.Regex.Match(Input.toString, "\w+(?=\s+\?)").Value.toString

Hope it helps!!

Hi @Honda

Get the word after a specific word i.e Job you can use

extractedValue = System.Text.RegularExpressions.Regex.Match(yourString, "(?<=Job\s)\w+\bOffer\b").Value

Get the word behind “?” use this

extractedValue =System.Text.RegularExpressions.Regex.Match(yourString, "\w+(?=\s?\?)").Value

Hope this helps

@Honda
yourString = “Got a Job Offer ?”
lastWord = System.Text.RegularExpressions.Regex.Match(yourString.TrimEnd("?"c), “\w+$”).Value

hope it is helpful!!

Hi @Honda

Can you try the below

LastWord = Input.TrimEnd("?"c).Trim.Split(" "c).Last

Regards,

Hello @Honda,
you can try this expression in an assign activity(str variable) -

System.Text.RegularExpressions.Regex.Matches(Str_, "[a-zA-Z]+").Cast(Of System.Text.RegularExpressions.Match)().Select(Function(m) m.Value).ToArray().Last.Tostring

If you find it usefull please mark this as soluttion.