Need help on regular expressions on these text

Hi everyone,

I am working on these following regular expressions on the the below texts. I tested with regular expressions at RegExr and Regex101 and they are working. But when I ran the regular expressions in UiPath, I got “Unrecognized escape sequence \K”. It appears \K is not supported on .Net Regular Expressions.

If .Net Regular Expressions does not support \K, what would be the alternatives to get the same result? I only need to capture the values in the text highlighted in bold.

Regular Expression:
Gb.*Gb.Gb\s+\K(\d+.\d+)
Text:
C: 99Gb 34Gb 65Gb 65.5
D: 99Gb 10Gb 89Gb 89.7
E: 49Gb 0Gb 49Gb 99.7

Regular Expression:
^Average.*:\s\K(\d+.\d+%)
Text:
Average CPU Utilisation: 2.2%

Regular Expression:
^Memory.*:\s\K(\d+.\d+%)
Text:
Memory Utilisation (4.2GB/8GB): 52.5%

Hi @michael.ho,

I made the same error at first.

On Regex101 you should use ECMA Script (JavaScript) Flavor

\K is only in PHP Flavor

To be on the safe side, use http://regexstorm.net/tester to test your regular expressions. It’s specifically made for testing regular expressions in .NET.

(?<=Gb.*Gb.+Gb\s+)\d+.\d+

image

Hi ptrobot,

Thank you for the help and as well as directing me to the regexstorm.net. All works now! Excellent!

1 Like

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