Unable to Scrap the text using Matches Activity

Below mentioned regex from is not working with UiPath matches activity.

“(?<=Full\sName\s)(.?([^\n]))”

Basically, I’m trying to extract the full name from text document by using above mentioned regex.
The mentioned expression able to find the matches when I’m checking with regexr or regex101 .

Attaching doc file for your reference.
Scrapp_2.txt (1.4 KB)

Hi @Omkar_Deshmukh ,

Could you try this instead?

(?<=Full\sName\r?\n).*$

Kind Regards,
Ashwin A.K

1 Like

@ashwin.ashok Nope, bad luck… it is not even matching

Hi @Omkar_Deshmukh ,

I altered the pattern based on the data you had provided, here is a screenshot for reference->
image

Could you check if the input data is accurate in the regex link I have provided above?

Kind Regards,
Ashwin A.K

Hi,

Can you try the following pattern?

(?<=Full\sName\r?\n).*

Regards,

Hi @Omkar_Deshmukh

Try this pattern

(?<=Full\sName\n).+

Regards
Gokul

Hi @ashwin.ashok ,

Yup, it is correct. but your regex expression is not correct.

Even, im trying to apply same it is not working for me…see it is not matching.

Hi @Omkar_Deshmukh ,

Oh alright, could you toggle it over to ECMA Script and try once more?

image

Or if you don’t want to do that, then try this pattern instead →

(?<=Full\sName\n).*$

Its better to reinforce it with a carriage return imo, but see if this works out for you.

Kind Regards,
Ashwin A.K

Hi Yoichi,

Thank you for the Solution. it is working absolutely fine.

If you can just explain where i was wrong in expression that would great learning for me.

Hi Gokul,

Thanks for reply.

Your expression is matching, but it was not giving the output. In output pannel when I’m logging the Regoutput(0), it is giving me “no value” as output

Hi,

If you can just explain where i was wrong in expression that would great learning for me.

Your pattern will match just 1 or 2 characters. Because there are only .? and ([^\n]).

"(?<=Full\sName\s)(.?([^\n]))"

So, quick repairing is to add * or + to [^\n] as the following.

On the other hands, [^\n] is same as . (period) in regex. And .? is probably for enable to handle both linebreak: CrLF and LF. As a result , the pattern will be

(?<=Full\sName\r?\n).*

And finally, FYI, regex 101 is not compatible with .net regex. And set Multiline mode as default. So this is reason why @ashwin.ashok 's pattern doesn’t work in Matches activity. On the conversely, If Multiline option of Matches activity is on, it might work, too.

Hope this helps you.

Regards,

1 Like

Very true @Yoichi ,

Silly mistake from my end, but its great since I got to learn something new today! :slightly_smiling_face:

Kind Regards,
Ashwin A.K

2 Likes

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