Ibra
September 18, 2018, 9:56am
1
Im extracting content from an email and i want to get the position of the sender e.g. advanced user, rookie, orchestrator etc.
And the pattern is the name of the person that is above the position .
I’ve tried alot to find a way to get the position but i always miss something.
Any ideas? Thank you.
skini76
September 18, 2018, 10:02am
2
From is not a problem, you can search for “From:” & extract the sender name using string functions.
The position is a tricky one, may be once you find the from user name, search again & assume the next line is position. But not sure how many times it will work.
indra
(Indra)
September 18, 2018, 10:04am
3
@Ibra Can you share whats input and whats the expected output with example
Ibra
September 18, 2018, 10:07am
4
The question is: when the name is always above the position of the sender and the senders name is repeated in the first line of the email content like the screenshot above “From: Ibra UiPath” → how is it possible to tell the program to ignore the first name and focus on the second in line?
Just a little thought, idk…
The input is an email content and the output is only the position “Ibra rokiee” (the only thing i want to retrieve here)
Ibra
September 18, 2018, 10:12am
5
I tried using this syntax:
(?<=Ibra UiPath)\s+.+
But its getting 2 values:
(newline) Test Email 1`
(newline) UiPath Rokiee
How can i remove the newlines and ignore the first value?
MAHESH1
(MAHESHKUMAR JV)
September 18, 2018, 10:15am
6
@Ibra
The name will not remain always constant right. So instead of using name use Best Regards
Regards,
Mahesh
Ibra
September 18, 2018, 10:18am
7
In UiPath studio i will use .Mail.Sender.DisplayName instead for an static value like the example i posted.
MAHESH1
(MAHESHKUMAR JV)
September 18, 2018, 10:25am
8
@Ibra
what if they use their Short names in Best Regards Section.
Regards,
Mahesh
Ibra
September 18, 2018, 10:31am
9
That will be ignored as long as i can get their name from the .mail.displayName.
evangemert
(Erik van Gemert)
September 18, 2018, 11:50am
12
Did you try and add the newline within the positive lookahead? For example:
(?<=Ibra Uipath[\n\r]).*(?=[\n\r])
Ibra
September 18, 2018, 12:02pm
13
It gave me an empty iterator. So i modified your syntax with this:
“(?<=Ibra UiPath[\n\r][\n\r][\n\r][\n\r]).*(?=[\n\r])”
And it worked.
But why does UiPath require MORE spaces (\n\r) than regex101.com ?
evangemert
(Erik van Gemert)
September 18, 2018, 12:08pm
14
Weird, but good to hear that it worked. Can you try and change it to this:
"(?<=Ibra Uipath[\n\r]+).*(?=[\n\r])”
That should work for any amount of subsequent newlines, 1 or more. I think that’ll be safer.
Ibra
September 18, 2018, 12:12pm
15
evangemert:
"(?<=Ibra Uipath[\n\r]+).*(?=[\n\r])”
That should work for any amount of subsequent newlines, 1 or more. I think that’ll be safer.
It took the first value “Test Email 1” instead of “UiPath rokkiee”
evangemert
(Erik van Gemert)
September 18, 2018, 12:31pm
16
Ahhh, of course. This should be the one:
"(?<=[\n\r]Ibra Uipath[\n\r]+).*(?=[\n\r])”
Ibra
September 19, 2018, 7:06am
17
Is it supposed to give the value with the index of 3?
evangemert
(Erik van Gemert)
September 19, 2018, 9:24am
18
No, that is because it matches every new line… Instead of .* between the brackets, try \S.* or \w.*
Ibra
September 19, 2018, 9:30am
19
Ok i just tried with \S* and \w.* but it returned null.
So i modified your syntax with this input:
“(?<=Ibra UiPath[\n\r]\s+)\s\S.*”
And it returned only the UiPath Rokiee
I dont know if this syntax i just used is too “simple” and can be unreliable. But it worked.
EDIT: I attach the .txt file as a zip.123.zip (226 Bytes)