Regex to Extract to extract two words from user name

Hi,
I want to extract the first name and last name from a Full name. Kindly help me to resolve this.

Sample Input : Jhon, Zach Firestone - USA

Expected Output :
FirstName: Jhon
LastName: Zach Firestone

Thanks in advance.

Hello

Assuming the comma and dash are constant Try the following:

First Name
Assign Left:
str_FirstName
Assign Right:
system.Text.RegularExpressions.Regex.Match(yourStr, “[^,]+”).ToString

Last Name
Assign Left:
str_LastName
Assign Right:
system.Text.RegularExpressions.Regex.Match(yourStr, “(?<=, )[^-]+”).ToString.Trim

Hopefully this helps,

Cheers

Steve

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.