How to get email address without domain using regex

Hi All,

I have a requirement to get the email address without domain using regex , any help would be appreciated

Example string abcd@xyz.com
Output abcd
Thanks

1 Like

Hi @jrin3753

Welcome to community
Check this out

System.Text.RegularExpressions.Regex.Replace(yourString.Substring(0,yourString.IndexOf(“@”)),“[^A-Za-z0-9]”,“”)

1 Like

I can have it in my assign right

Yes @jrin3753

You can have the output stored to a required variable

Sample20230428-3L.zip (2.2 KB)

system.text.regularexpression.regex.match(yourstring,“[A-Za-z0-9][?=@]“)
or
system.text.regularexpression.regex.match(yourstring,”[A-Za-z0-9]
[?=@]”).value
output gives as you required

1 Like

Hi @jrin3753

Try with the below Regex expression

MicrosoftTeams-image (1)

Regards,

1 Like

Just shared you a sample code for reference above @jrin3753

Happy Automation

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