Matches (regex)

word
regex

#1

Hi, i want extract data in word document. The data is between words
So i use this regex

(?<=(REFERENCE))(\w|\d|\n|[(.*)]| )+?(?=( CAHIER))

When i try it on https://regex101.com, it’s work fine, but on uipath the result is always null/empty.
How i can resolve this ?

Thank for your reponse
Have a good day

The document is

REFERENCE

000000

CAHIER


#2

Hello @Tulifer,

Your regex “(?<=(REFERENCE))(\w|\d|\n|[(.*)]| )+?(?=( CAHIER))” only works on https://regex101.com, with global regex flag:

This regex: “(?<=REFERENCE)[\s\S]*(?=CAHIER)” works in UiPath Studio

Matches.zip (2.6 KB)

Regards,
Susana


Dynamic text
#3

This will work too “(?<=REFERENCE)(.*)(?=CAHIER)"


#4

@Susana & @palindrome Thanks for your reply, it’s work fine.

Now i try other text like.
So i use the same method

(?<= Liste des questions : )[\s\S]*(?=Liste )

Why doesn’t work when i have : in my sentence ?

Liste des questions :

aaaaaaaaaaaaaaaaaaaaaa

Liste des réponses :


#5

Did you check for spaces? Try to use variables with Trim property which will remove all the leading and trialing spaces.

(?<=Liste des questions :)[\s\S]*(?=Liste)

For those who are not fans of Regex can try this

Line.Split(New String() {"REFERENCE","CAHIER"}, StringSplitOptions.RemoveEmptyEntries)(0)


#6

Hi,
I have total of 3 different Regex patterns, is it possible to make a regex engine comprising of all the three patterns?
what i am currently doing is, my pdf text is passing through first pattern, if the count is returning 0, it goes through second pattern and so on.
Is it possible that the pdf text extracted passes through all the 3 patterns at once??


#7

Keep your patterns in Array and use foreach loop with matches activity, keep if condition inside foreach loop to check the condition.


#8

Hi,
Thanks for your reply, i am trying to do as you suggested but i am getting the below error.
image

I have stored all my Patterns in an array RegexPattern and passing the same into matches.

image

image