Reg ex look behind


Need to find lookbehind word logic for regex.
I have below string.
“It sees hopefully you are doing well”
I need to find 2 words before “are” that is “you” and “hopefully” using regex
pls help


Hi @sshitol

Try this



Hi @AshwinS2,
As i mentioned i need only 2 words before “are” so can you help me in this

Hi @sshitol,

Not sure if I read your question properly, but you could do something like this to get the two words before are (using a look-ahead actually):
Again, if you want to split these words into two you could go further from there.

Let me know if this helps :slight_smile:


Hi @mcicca,
Its working.
But suppose i need to capture 20 words before “are” then what I have to do in above regex?


Try something like this:

Where you can replace the 19 with whatever number you want to suit your needs :slight_smile:

1 Like

Hi @mcicca,
Thanks it work for me.
Can you pls help me out suppose i need to find 2 words before “are” and 2 words after “are” at a same time. Can you give me regex for that?

Hi, @mcicca
I am facing issue in regex.

If yoy see the last line in Test string it is also having “By” word but its not highlighting word which are present before and after that.
Can you help me. I guess because of . its creating problem
I need such regex which can accept anyvalue (number,word,special character) after and before “by”

Hello @sshitol
Try this pattern \S(?:\s\S+){0} by \S(?:\s\S+){0}**

Please note here the count starts from 0

1 Like

Hi @vickydas,
Its working fine in regex101. But when I am reading that from text file and entering that variable into matches activity. It giving me none in return while I am changing count in regex from 0 to 7.

Hi @vickydas,
I am attaching notepad which contain text. try to run it on that text using read file activity.
with different number of combination of number you are passing in {} regex.
Because its not working in my system.
COuld you pls tell me which version of uipath you are using (22.9 KB)

hello @sshitol
Its working on my system i read your txt file and it gave me proper output
I am using 2019.6.0

Hello @vickydas.
Pls change number that you are passing in {}. Make it 8 or 9 in hoth{}.
And then check.

hello @sshitol
Looks like the text format is getting distorted in someway when i pass it through a variable because when i insert the same text manually as input it works and when i insert it through a variable i get blank output.
If i insert a smaller digit i get correct output but as i increase the number i get blank output
Till the digit 3 i am getting output after thats its getting blank

Yes same issue i am talking about…any solution on this?

hello @sshitol for the time being if you can than try to input the text manually as an input without passing it through variable.(If you are using Matches Activity)
I’ll let you know once if i find anything about this issue

Hi @vickydas.
Ok i ll do that and thanks for all your help on this issue.