Regex pattern working in regexr but match activity is giving null value

Hello Every one,

My regex pattern able to match the required data in both UiPath regex builder as well regexr

but the problem is UiPath matches activity out put is null no values
image

not able to extract the text even thou able to match the text, can anyone help me with it?

my pattern: “Next Activity:\n(.*)”

@Chethan_M1

Attach the input sample and output also

Hi @Chethan_M1

Try this:

Assign-> Input ="Major Equipments Not Working:                  Next Activity:
Iron roughneck.                        Drill 81/2" production hole to section TD at 52,000'."

Assign-> Output = System.Text.RegularExpressions.Regex.Match(Input,"(?<=Next Activity\:\s*\n).*").Value.Trim()


If possible share the input so that I can help you with further regex expressions.

Hope it helps!!

Hi,

It may be line break matter. Can you try to use \r?\n instead of \n

Regards,

Hi @Chethan_M1

You can directly use the Regular expressions in assign activity to get the required output without using Find Matching Patterns activity.

- Assign -> Input = "Major Equipment Not Working:                Next Activity:
                     Iron RoughNeck:                      Drill 81/2" production hole to section TD at 52,000'."

- Assign -> Output = System.Text.RegularExpressions.Regex.Match(Input.toString, "(?<=Next Activity:\s).*").Value

Check the output in Regexr -

Check the below workflow for better understanding,

Hope it helps!!

Thank you @Parvathy I’m able to get exact multiple values

output: varable(0): Drill 12 1/4" hole to ~ 12,075’.
varable(1): Run 9-5/8" casing to planned shoe depth 13,311’ and cement same

I have question: why you used \s* in regex pattern ?

Hi @Chethan_M1

\s: Matches any whitespace character, including spaces, tabs, and newline characters.
*: Quantifier that matches the preceding element (in this case, \s) zero or more times.

So, \s* will match any sequence of zero or more whitespace characters.

Hope you understand!!

Hi @Yoichi , even through your solution I’m able to get all multi values thank you but no 2nd option to mark ur solution as solved :sweat_smile:

wanna know why you used \r? in regex pattern

Yes! now it’s clear, once again thank you @Parvathy

1 Like

Hi,

Windows type linebreak is CR+LF (\r\n)
Unix type line break is LF (\n)

So \r?\n will match both type of linebreak. In this pattern, \r? is 0 or 1 \r character match.

Regards,

Understood, thanks @Yoichi

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