Dear all
I have to identify a 8 character long usernames in a email body.
My idea is to parse the complete text (from an email body) and find all words that is 8 characters long and look them up in the user database.
My question: How to identify all words in a text which is 8 char long?
Remark: a username can be both letters and numbers eg: A1234567, Test1234, abcdefg1 or 1234567A etc.
Thanks!
Dominic
(Dominic)
January 31, 2018, 11:50am
2
@robert.justesen , The best way is to use Regex
In Matches Activity,
Input - Your Email body which is a string
pattern - ([A-Z0-9a-z]{8})
Output - Save to a variable of type (Ienumerbale(of match))
Regardfs,
Dominic
2 Likes
arivu96
(Arivazhagan A)
January 31, 2018, 12:28pm
3
Hi @robert.justesen ,
@Dominic if you use regex sometime return false if mail length is small
For Example Mail id is strMail = a1c2v3@gmail.com
IntMailIdLength=strMail.Split("@"c)(0).ToString.Length
if condition IntMailIdLength<=8
Then
strUserName=strMail.Split("@“c)(0).ToString
else
strUserName=strMail.Split(”@"c)(0).Substring(0,7)
Regards,
Arivu
Dominic
(Dominic)
January 31, 2018, 12:31pm
4
@arivu96 , As robert requirement is to match from Mail Body not from Mail Id
@robert.justesen , Correct me if I am wrong .
Regards,
Dominic
1 Like
Thanks for your reply’s
Yes - it is from the mail body and the username is not an e-mail
The Mail.Body could look something like this:
Dear Mr. Justesen
My old username for the Microsoft system is X1234567 and …
BR Justesen
The accepted result is:
Justesen
username
X1234567
Justesen
With the ([A-Z0-9a-z]{8}) I’m also getting Microsof as a result.
Resolved it with a \b before and after:
Regex.Matches(Mail.Body,“\b([A-Z0-9a-z]{8})\b”)
Thanks !!
3 Likes