RegEx pattern with variying space

Hey guys.

My text looks like this:

Line 1 31 32
Line 2 12 14
Line 3 56 78

I want to create a RegEx code for UiPath, that extracts whatever number (in this case 14) that is in the end of line 2. A little challenge is, that I the spaces between the numbers can change. Here we got 5 spaces, but it could be 2 or 12, if that make sense.

Please help me :slightly_smiling_face:

@LauraMM
give a try on the pattern below
grafik

2 Likes

Definately, but I only want the number in the end of Line 2. So I need to add something.

can you the local panel view for the text variable.

  • Maybe we split on Environment.NewLine and take the second line
  • can take the second match only
  • Maybe we can anchor to “Line 2” text

Also check following:
grafik
with the retrieval of group 1
grafik

2 Likes

Hey ppr.

It doesn’t work. Or your code will take the entire second like. What I want it to do is to scan the input:

Line 1 31 32
Line 2 12 14
Line 3 56 78

And if we have a “Line 2”, it should extract the 14.

The input varies, as the spaces between the numbers could be more than 1.

But you fetched the Group value and Not the Match value, right?

1 Like

I am not sure, what you mean?

I’ve pasted in your code in regex101 (the extracted looks like yours), but putting in the same code in regexr give me a different result. See below:

refer to my screenshot from above where the value of interest is in group1. But give me some little time I will prepare some demo on different approaches for this case and willo share with you

1 Like

Thank you for your great effort. I am a little unsure, what I should copy of out of the expression to get the value of interest?

@LauraMM
just as a preview

Find demo case xaml here:
Get_2ndLine_PartRetrieval.xaml (6.1 KB)

2 Likes

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