I have a string like this “mich.bommattrto@abc.com ; Tom.Szski@abc.com ; Chaterd.Andrs@abc.com ” and I want to extract mich_Tom_Chaterd 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
ppr
(Peter Preuss)
April 22, 2021, 9:33pm
2
@faiqaqureshi90
have a look here:
String.Join("_",(Regex.Matches(strText,"(\.|\w)*?(?=\@)").Cast(Of Match).Select(Function (x) x.toString.Split("."c)(0))))
Ensure following:
Challenging it with missing dots:
Its Working
Can you please explain this?
Assign-0:
Str_Mails = “
mich.bommattrto@abc.com ;
Tom.Szski@abc.com ;
Chaterd.Andrs@abc.com ”
Assign-1:
Str_Test = Str_Test + Split(Mail.Trim,“.”)(0) + “_”
Assign-2:
Str_Test = Str_Test.Substring(0,Str_Test.Length-1)
ppr
(Peter Preuss)
April 22, 2021, 9:43pm
5
Regex - Regex101.com
With regex we do take all strings before the @
character
From all matches we do a split on the dot and take the first item
With String.Join we do surround the items with a “_”
1 Like
Thanks Alot
It really helped
system
(system)
Closed
April 25, 2021, 9:46pm
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.