Regex cant match

Hello

I am trying to match the second URL in this text

Your ID: https://acmecorp.com/wp-content/uploads/elementor/forms/capt0005.jpg
https://acmecorp.com/wp-content/uploads/elementor/forms/c002312.jpg
Your drivers licence: https://acmecorp.com/wp-content/uploads/elementor/forms/67b18510f5.jpg
https://acmecorp.com/wp-content/uploads/elementor/forms/img0927f3.jpg

For each Your ID and also Your drivers licence. All i want to know correct regex pattern.

Your ID:\s+https?:\/\/\S+\r?\n(https?:\/\/\S+)
Your drivers licence:\s+https?:\/\/\S+\r?\n(https?:\/\/\S+)

So this one would work well in regex101 using .net and also .NET Regex Tester - Regex Storm which was recommended but anything i try it wont work, whether i try to use regex builder and also typical assign. I am at the end of it really dont know what to these regexs are so stubborn. First links work no problem.

Many thanks for any help!

1 Like

@lc1917

try this

(?<=Your ID:\s+https?:\/\/\S+(\r?\n)*)(https?:\/\/\S+)

System.Text.RegularExpressions.Regex.Match(String,"(?<=Your ID:\s+https?:\/\/\S+(\r?\n)*)(https?:\/\/\S+)",RegexOptions.MultiLine).Value

this also would work…I hope the newline is always there

(?<=Your ID:.*(\r?\n)+)(https?:\/\/\S+)

similarly second one

(?<=Your drivers licence:\s+https?:\/\/\S+(\r?\n)*)(https?:\/\/\S+)

cheers

Hi @lc1917

Your Regex is perfect :rocket: . One addition needed. For the next line use “\n”

This is your Updated Regex:

Your ID:\s+https?:\/\/\S+\r?\n(https?:\/\/\S+)\nYour drivers licence:\s+https?:\/\/\S+\r?\n(https?:\/\/\S+)

And, Your regex extracts the ID and DL as separate groups. So, use the following assign:

yourID = System.Text.RegularExpressions.Regex.Match(inputString, "Your ID:\s+https?:\/\/\S+\r?\n(https?:\/\/\S+)\nYour drivers licence:\s+https?:\/\/\S+\r?\n(https?:\/\/\S+)").Groups(1).Value
yourDL = System.Text.RegularExpressions.Regex.Match(inputString, "Your ID:\s+https?:\/\/\S+\r?\n(https?:\/\/\S+)\nYour drivers licence:\s+https?:\/\/\S+\r?\n(https?:\/\/\S+)").Groups(2).Value

The Output:

If this solves your issue, do mark it as a solution.

Happy Automation :star_struck:

You can refer below link for URL Regex

Hi @lc1917

Your regular expressions are perfectly working. Are you facing any issues?

i have no clue what is happening here:

this is coming from gmail

this is mystery for me :frowning:

Hey @lc1917

Could you check GmailContents.Body on the Immediate Panel

Something’s wrong there.

Immediate panel is empty

You need type in GmailContents.Body and click enter

ok…

1 Like

Now copy paste this String on Regex 101 website and try the Regex.

Hmmmmmm thats actually a feature i didnt know about… i guess because my email is actually a fw: so there is something invisible to my eyes but probably not to regex:

image

so that is maybe why it would not take always the second line…

1 Like

ok did that and yet it wouldnt work (on this particular example which does not have > )

i am not sure if the empty space is part of the Intermediate window just…so i should not take it into regard in regex101 ?

Copy everything between the “”

yes did…obviously it adds whitespace before on each line…i guess that is of the interrmmediate window there…but it still does not work in UiPath…regex101 yes in Regex Storm no

OK i got it sorted, the hint with Intermmediate Window was solution to me as i had wrong input and then adjusted the regex similar to @V_Roboto_V one just made in 2 parts (as it may have only one link at times so that would not work well everytime).

"Your ID:\s*\r?\n\s*(https?:\/\/\S+)\r?\n\s*(https?:\/\/\S+)"
"Your drivers licence:\s*\r?\n\s*(https?:\/\/\S+)\r?\n\s*(https?:\/\/\S+)"

Cheers!

2 Likes

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