Matches (regex)

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, 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




1 Like

Hello @Tulifer,

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

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



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

1 Like

@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 :


Liste des réponses :

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)

1 Like

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??

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

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

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