Regex pattern with starts with(^) and ends with($) not working in Uipath matches activity

Hi Guys,
I tried to create a pattern using regex in matches activity in uipath but its not recognising
Starts with and Ends with
Why is this?
Can anyone share a workflow where youve used ^ and $ in your expression please

may we ask you for your sample text, the pattern and a small description of expected output? Thanks

sample scenario1:

2717000 10

sample scenario2:

2717000 10 industry

sample scenario3:



Ineed to pick 2717000 in any of these 3 scenarios

Hello @Dheeraj_S ,

Other pattern

pattern = "(?<=Description\s\d{7}\s)\d{7}"

(link to result on regex101 below)

Multline Match

Did you use Multiline RegexOption?

import System.Text.RegularExpressions

pattern = "Description\s+^\d+\s+^(?<result>\d+)"
match = Regex.Match(myText, pattern, RegexOption.Multiline)


Hello @msan,

The word description is not constant, it keeps changing.
The only constant things are the two 7 digit numbers.


hfgwhfgigfjsdjgfjg 1000 djhg
2717000 10

give a try and refer to group 1


description 30733459 2000279367
2717000 10

For the above text i’m getting 3 matches with your pattern.
i should only get one

adopt with (?<=^\d{7})\s*(\d{7})


@ppr It works:)
What if the text changes in this way.How to change the pattern to adopt this change given below:
description 30733459 2000279367
2717000 10

description 30733459 2000279367
2717000 10

description 30733459 2000279367
7731642 10

In every case we need to pick 2717000.
Occasionally there will be a 7 digit reference number above this but not every time.


You should provide right away all variations you can think of in the samples :slight_smile: We’re not only writting a regex here but mainly trying to find a pattern to then express as regex. In that process we tend to spot what doesn’t change and how the variations work.

May I assume you’re simply looking for the last seven digits number?

pattern = ".+(?<result>\b\d{7}\b).*?$"
match = Regex.Match(myText, pattern, RegexOption.Singleline)
result = match.Groups("result").ToString
1 Like

@msan Read pdf with ocr is giving unexpected output so i was trying out various parameters so i couldnt give out all the variations at once.

Yes i’m looking for the last seven digit number which is sometimes preceeded by another 7 digit number as shown in the example.

Since the ocr is not getting all the relevant data out of the pdf i’m having trouble forming patterns.

Thanks for your response


Don’t worry, I’ve guessed it. But it as you will get more case, you’ll probably have to do this again.

And you’ll thanks me later: collect many samples first and you’ll have a better reading of the patterns. Then the regex is just an expression.

Will do. Thank you so much:)

Because you’re always looking for this 2717000 in each scenario why don’t you just look for that rather than having an overly complicated regex? Example below…the site I use to validate my regex patterns is

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