Extract String

I have a string like this “mich.bommattrto@abc.com; Tom.Szski@abc.com;Chaterd.Andrs@abc.com]” and I want to extract michB_TomS_ChaterdA from this string.

This string contains 3 emails but there are strings that contains 1,2 or more than 3 emails.I want a generic solution

give a try on following:

arrString =

Regex.Matches(strText,"(\w+)\.(\w)\w*(?=@)").Cast(of Match).Select(Function (m) m.Groups(1).toString & m.Groups(2).toString.ToUpper).toArray

finaly we can fine tune the regex e.g.

1 Like

Using this regex will extract the @example.com with one email address or more:

@(.*?)(;|$)

Hey @faiqaqureshi90 ,

I got it:

(^|(?<=;))(.*?)(?=@)

This regex will get you all the “usernames” of these email addresses whether there is one or many.

Here is a link if you would like to see how it works: RegExr: Learn, Build, & Test RegEx