Get text after string and ignore any spaces

Hi,

Struggling to get the text after a string and ignoring any spaces between the text I’m searching after and the beginning of the text I want to extract.

“JS Jeff ShumUserMenu”

Desired Result is “Jeff Shum”. Ideal result is to be able to capture first name and last name of anyone.

Regards,

Jeff

@JeffNZ1 - You can try this Regex pattern…

Assumption: After the Last Name there will be usermenu always..

StrFNLN= Regex.Match(“JS Jeff ShumUserMenu”,“(?<=\s*)\w+\s*?\w+(?=UserMenu)”).value

Import : System.text.regularexpressions (if Regex.Match did not recognize)

image

3 Likes

Thanks for that. The string that I’m trying to extract is data scraped from a string to a variable. How can I embed that code to reference the data scraped variable? e.g. my Data scraped variable is called “extracted user name”.

Regards,

Jeff

@JeffNZ1 - if your datascraped variable is called extracted user name then …

StrFNLN= Regex.Match(extracted user name,“(?<=\s*)\w+\s*?\w+(?=UserMenu)”).value

Here StrFNLN is a string variable.