String Manipulation : Extract Name from Email Subject

Hi All,

Facing issue in extraction of name from an email subject.

Input : “RE: 9967_Rihan Joshi ABC & Student Certificate”
Expected output : Rihan Joshi

Input : “RE: 6514_Archana & Student Certificate”
Expected Output : Archana

Any help would be appreciated. :grinning:

Hi @Happy_Coding

Use this regex:

(?<=RE\:\s+\d+\_)[A-Za-z]+

Regards

Hi @Happy_Coding

Check out the below workflow:

Input = "RE: 9967_Rihan Joshi ABC & Student Certificate"
Output = System.Text.RegularExpressions.Regex.Match(Input,"(?<=RE\:\s+\d+_)[A-Za-z]+").Value.Trim()

Input = "RE: 6514_Archana & Student Certificate"
Output = System.Text.RegularExpressions.Regex.Match(Input,"(?<=RE\:\s+\d+_)[A-Za-z]+").Value.Trim()

Hope it helps!!

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=\d+_).*?(?=(\s[A-Z]+)?\s\W)").Value

Regards,

@Yoichi , Thanks It worked absolutely fine.

Can you help with one more

Input : RE: 9999_Rihan Joshi ABC & Students Certificate
Output : “9999_Rihan Joshi”

Input : RE: 9999_Rihan ABC & Students Certificate
Output : Rihan

Cheers :boom:

Hi @Happy_Coding

Try this

(?<=\_).*(?=\s+\w+\s+\&)

image

or

(([0-9]+\_\w+\s+\w+))

(?<=\_).*(?=\s+\w+\s+\&)

image

Regards,

Hi @Happy_Coding

Try this:

Input = "RE: 9999_Rihan Joshi ABC & Students Certificate"
Output = System.Text.RegularExpressions.Regex.Match(Input,"(?<=\d+_).*?(?=(\s[A-Z]+)?\s\W)").Value.Trim()
Input = "RE: 9999_Rihan ABC & Students Certificate"
Output = System.Text.RegularExpressions.Regex.Match(Input,"(?<=\d+_).*?(?=(\s[A-Z]+)?\s\W)").Value.Trim()

Hope it helps!!

Hi @Happy_Coding

Check the below workflow for better understanding:

Input = "RE: 9999_Rihan Joshi ABC & Students Certificate"
Output = System.Text.RegularExpressions.Regex.Match(Input,"(?<=\d+_).*?(?=(\s[A-Z]+)?\s\W)").Value.Trim()

Input = "RE: 9999_Rihan ABC & Students Certificate"
Output = System.Text.RegularExpressions.Regex.Match(Input,"(?<=\d+_).*?(?=(\s[A-Z]+)?\s\W)").Value.Trim()

Regards

Hi,

Can you clarify you requirement a little more?
Do you need single expression for the above 2 examples or need 2 expressions independently?

If former, also clarify the condition to add numeric characters such as 9999?

Or need single expression for all the 4 examples (including the first post)?

Regards,