Extract multiple URLs from a given text using Regular Expressions in UiPath

Hi All,

I am trying to extract two URLs with the “.csv” extension by using regular expressions in UiPath. But I’m getting only one URL instead of two.

The below pasted is my text from which the URLs are to be extracted.

The links will expire in 48 hours.

*https://restaurant.uber.com/payments/comprehensive-pay-statement/0167beaa-d88e-4318-94d9-7b0d414bc15d/659b6d11-8446-4a3c-a08c-e56850505ac3-united_states.csv https://email.uber.com/wf/click?upn=DnUSR-2B2zJI07XNaWR-2Fwm8OxHU3WUMSviNJZlZUvTw1MHitwbrC9gTozADPtVq3ZifIjDhK6FkXQ0r7KF6Pkra4BRLezY5ZJ-2BhCgj1YfG-2BuXjM5XT5raPFuerk9BpIvHPWdK-2BVT2exQbfuNL6A8qrWJXUxqoJoq2UndJSLeCDJ8DkTX4ygBnJbSgzE9118Sd-2BqaTXflKYmlLIlinh3om-2F5EqNqB3ffz27P6V7O-2BnC9HI-3D_ASkf8Jm-2FvZu3ne6CGEw0qunUXL-2Flh26XUw8NHThZJEZw7lr7luyXO-2Bg81WskkjZSXy2jjnF0JTsRGm4smsp9ZQt4RhWGTOjB-2FZKryOETpaRrqH-2FUC-2FK-2FHasoYS3bEcP06b3Yq-2BncNNiZhAodjSVH6Kgl76zqw-2B0tdHRQnhy54lHSt3FUIbtdWQf3QIRuD1yb8i61r3Qf4NagZoF0VZM2-2BSDY8irHghu661cjjeYFIrkr6VIDjxeY-2Fqq58f-2FGBxIP67eABDF4wBTjZPSm3-2F7j4kMMxWVP2lUUCtoXrwrwtFfePxMhg4T4rnd5MdjA2kx3QxUmOGGlUF7IHzejy7IGx62e6hK4bqIf1cOOHYhUa-2FwBmQeSFtHRMl2GO8QfrQ610VO7G-2F6I-2Fw6aaXLj8wc8TcnhcFgFbMSq3MHhIw3BQv62ipWnA8jIyfbrHLiNhjbIN4BkFD8ljG-2FX-2BX-2BWZ90SVBoxNs2dVXkkyREVdEkjQWE-3D *

https://restaurant.uber.com/payments/comprehensive-pay-statement/0167beaa-d88e-4318-94d9-7b0d414bc15d/659b6d11-8446-4a3c-a08c-e56850505ac3-canada.csv https://email.uber.com/wf/click?upn=DnUSR-2B2zJI07XNaWR-2Fwm8OxHU3WUMSviNJZlZUvTw1MHitwbrC9gTozADPtVq3ZifIjDhK6FkXQ0r7KF6Pkra4BRLezY5ZJ-2BhCgj1YfG-2BuXjM5XT5raPFuerk9BpIvHPWdK-2BVT2exQbfuNL6A8qrWJXUxqoJoq2UndJSLeCDJ8DkTX4ygBnJbSgzE9118Sd-2BNhJjTdATpsGXjQa3wQTXHw-3D-3D_ASkf8Jm-2FvZu3ne6CGEw0qunUXL-2Flh26XUw8NHThZJEZw7lr7luyXO-2Bg81WskkjZSXy2jjnF0JTsRGm4smsp9ZQt4RhWGTOjB-2FZKryOETpaRrqH-2FUC-2FK-2FHasoYS3bEcP06b3Yq-2BncNNiZhAodjSVH6Kgl76zqw-2B0tdHRQnhy54lHSt3FUIbtdWQf3QIRuD1yb8i61r3Qf4NagZoF0VZM2-2BSDY8irHghu661cjjeYFIrkr6VIDjxeY-2Fqq58f-2FGBxIP67eABDF4wBTjZPSm3-2F7j4kMMxWVP2lUUCtoXrwrwtFfePxMhg4T4rnd5MdjA2kx3QxUmOGGlUF7IHzejy7IGx37m-2BldFy0P20pZ5tuRbQozGoG61t3Ei0d5Zp-2B-2BcZip2MCTo0MCkgK3A8uTz4joOkTjYuv-2FoY5zVb2-2F9EXiniOUsWQeRXFYzg8pap2wzBqpub6dO04etKuAWIcFAWmSx90iKLhEuarVfMgx5f1wzmmI-3D

The regular expression I have written is
System.Text.RegularExpressions.Regex.Match(Mailmsg,"(?<=\s)(https).*(?=<https://email.uber.com)")

Anyone help me out in solving this.

1 Like

kindly check the occurrence value provided in the regex activity. If you have kept as “0”, only the first occurrence will be extracted. If the value is “1”, the 2nd occurrence is extracted. Make the occurrence value as dynamic and check once.

Hi
Welcome to uipath community

Kindly try with this expression
And it’s working as well

System.Text.RegularExpressions.Regex.Match(Mailmsg,"^.*(?=https)”)

Cheers @Anveshs

Hi,
Please Try this:(?=https).*(?=https://email.uber.com)

Hi @Anveshs,

If yo only want to get the URLs containing csv then, please use Matches activity where you can get multiple outputs when matches.

Please use the below pattern format to get the required two links -
(?=https)(.*)(?>csv)
The above pattern is tested and works fine.

Hope it will help you.

Thanks & regards,
Apurba

Thank you all for your quick response. Finally got the solution.

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