[REGEX] - expression works correctly in regexstorm.net but UiPath output is empty

Hi everyone,

I’m building an automation that reads the body of a set amount of e-mails, and then uses REGEX patterns to extract the hyperlink contained in the body.

The following regex expression is functioning in .NET Regex Tester - Regex Storm but the output in UiPath comes up empty. I used regexstorm.net because I’ve read it’s the most reliable way to test expressions compatible with UiPath.

REG Expression:
(?<=endereço: \r\n\r\n).*?(?<=3d%3d)

Output of e-mail body:
\r\n\r\n \r\n\r\nSaphetyDoc \r\n\r\nElectronic Invoicing \r\n\r\nFatura : ZF2E 1/1190001179 \r\n\r\n https://doc-server-qa.saphety.com/Doc.WebApi.Services/api/Entity/logo/stream/PT500498601/20211011154009.3c508e68-1f95-4096-a7bc-3ce4f0153255 \r\n\r\n \r\n\r\nCaro(a) Utilizador(a), \r\n\r\nA entidade CP - Comboios de Portugal (PT500498601) enviou o seguinte documento eletrónico via SaphetyDoc: \r\n\r\nDocumento \r\n\r\nFatura : ZF2E 1/1190001179 \r\n\r\nData do documento \r\n\r\n2021-10-11 \r\n\r\nPode obter o documento no seguinte endereço: \r\n\r\nhttps://doc-server-qa.saphety.com/Doc.Client/public/doc/pt?token=GmxQbXsXu4ohQo2Wx7q3o9bG8hZ7IkRvY0NvcnJlbGF0aW9uSWQiOiIyMDIxMTAxMTE1NDAwOS4zYzUwOGU2OC0xZjk1LTQwOTYtYTdiYy0zY2U0ZjAxNTMyNTUiLCJTZW5kZXIiOiJQVDUwMDQ5ODYwMSIsIkRlc3RpbmF0aW9uIjoiUFQ1MDAyOTcxNzciLCJSZWFkZXJJZCI6ImZpbGlwZS5tb2l0YUBhYnJldS5wdCIsIkNoYW5uZWwiOiJNYWlsRG93bmxvYWRUb2tlbiIsIkV4cGlyYXRpb25EYXRlIjpudWxsfQ%3d%3d http://url3710.saphety.com/ls/click?upn=qCkLLb9cYeFFz87dkwx3qDuniWNDSjbM8atB-2FM80jq0qgPRFnKwHl0sm-2B9bCpVp9leGBDPGS5s9Z5kZx5SV6PnnC0kxN-2FARlmAVn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\nsaphety.com http://url3710.saphety.com/ls/click?upn=qCkLLb9cYeFFz87dkwx3qNqF1SClfMN2GAPn8T-2FLkuzfDl2GkERAUUFFOk399cODWqHD_gC44qKU9iQWarZN-2FIpDhJa25YRzjf-2BlziikefbClqRj8jyHIFy-2B7qhO1a7XvTlFW-2BNk7BgvmsARNW4oiOOhpxXexemX8kYLVkoqbCGcbvORJ4GGxpuTTQa-2B4CDWyBXnRvLXlus-2FwiNYKoBB3ga8JkOx0T29k6oAPvV5hnRYRAtrN3dyTllKT6q75dn3-2Fi6z9Uob8ynVYZ3iXKfuIqpHkSnBEnvnhItPq0lkUN21oxWaPNZqTLU8NqEQeKU8SlO7FrZPHxR1Ukk9DF5mAhsMNcqaZiTXi2hoCRqCBrh-2FzJ06AROzuKWSz5uIcGCTOwXzsvEgUiITbzaxQg5LQ7X80QA-3D-3D \r\n\r\n \r\n\r\n \r\n

Am I missing something obvious?

Thanks in advance.

Hey @andre.f.pires

Can you please provide the Sample, the expected Output and as much information on the Pattern as you can.

In the meantime, I believe the problem was that you were not ‘escaping’ the characters of “\r” and “\n”. To ‘escape’ a character you need to insert a “\” in front of it. However, a “\r” means a return, a “\n” means a new line. This confuses things when you have them in square brackets [ ]. See my Potential Solution 2 and 3 where I have handled the letters r,n and \ individually. The source file convert the “\r” and “\n” accordingly but when imported into UiPath they are literal text values.

Potential Solution 1:
Preview this pattern:
(?<=endereço: \\r\\n\\r\\n).*?(?<=3d%3d)

Potential Solution 2:
Preview pattern here
(?<=endereço: [rn\])[^rn\].?(?<=3d%3d)
Comments: This solution will not matter how many ‘\r’ or ‘\n’ there are in the text AS LONG as the start of the link doesnt begin with an r,n or \ which it could…

Potential Solution 3:
(?<=endereço: [rn\\][\w])[\w]{2,}.?(?<=3d%3d)
Preview link
This pattern will work regardless of the first letter in the hyperlink.

Hi,

I think you want to extract URL after endereço Keyword, right?
I recommend to use the following expression, because 3d%3d in your pattern will be needed in the URL. %3d means “=” and it’s base64 padding character. So if orginal data length changed, length of padding characters might be also changed from 0 to 3.

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=endereço:[\s\S]+?)https://\S+").Value

Regards,

Much appreciated, that works just fine.

Thank you!

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