Regex - Match activity - No results

Hello everyone,

I am facing issue with my regex. I have a invalid json file and I need to match one exact part.
My regex works on regex101 and also in the UiPath editor, but in runtime I am getting no results.

Can you help me out? Is it a regex flag problem?

My regex: (?<=EXCEPTION_REASON",\s{5}“value”\s:\s")[\s\S]*(?="\s{3}}\s]\s})
Test string:
“key” : “EXCEPTION_REASON”,
“value” : “First line of text
Second line of text
Third line of text”
} ]
}



image

Thanks, Eduard.

Hi

Did we try to mention that matches output variable in a writeline activity and check for output
Like this
matches(0).ToString

If it is coming in editor then output will come for sure

Cheers @Eduard

Hey, yes I did, it´s empty - as you can see the matches object is empty on the screenshot.
Thanks!

It’s ienumerable
Mention the index position

Only then we can see the value
@Eduard

Hey, even in writeline there are no results for my regex:

I would like to know whether Is it coming in matches or group when tested in regex101
@Eduard

Hi @Eduard
use matches.ElementAt(0).ToString

Hi

Then try with the his expression in a assign activity

Str_output = System.Text.RegularExpressions.Regex.Match(str_input,”your expression”).ToString

Cheers @Eduard

I did try this, same result - returns no value

Hmm

Make sure input variable has some value in it or the right input is passed to the activity

@Eduard

Hi @Eduard
Try this pattern

(?<="EXCEPTION_REASON",\s+"value" : ")[\w\r\s]+

, TRY this pattern

Regards,
Nived N
Happy Automation

Quantifier is not allowed to be used in lookarounds.

It could be the case that the windows typlical line breaks composed by \r\n
will lead to failling due 5 is less then needed

(?<=EXCEPTION_REASON",\s{5}“value”\s:\s")[\s\S]*(?="\s{3}}\s]\s})

Ok so what is the pattern you propose? Strange is that the one I use works both in 101regex and UiPath studio regex editor - but not in runtime.

you readin a text file, right? then the \r\n comes into picture

Love it, you helped me solve it after half day.
So the working regex is like this:

(?<=EXCEPTION_REASON",(\r\n|\r|\n)\s{4}“value”\s:\s")[\s\S]*(?="(\r\n|\r|\n)\s{2}}\s])

@Eduard
have a look on following:
(?<=EXCEPTION_REASON",(\r?\n|\r?|\n)\s{4}“value”\s:\s")[\s\S]*(?="(\r?\n|\r?|\n)\s{2}}\s])
then we are compatible in both worlds but will not validate in regex101, but maybe works with regexstorm

As an alternate we can do:
grafik
grafik

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