RegEx usage help

Hello guys. I have sorted out a regex code to help me with the workflow, but cant seem to know how to use it :smiley:

The thing is, that im trying to take the numbers after the text “inverior to "”
This is the text:
{
“msg”: “Page "24" does not exist. The currentPage must be inferior to "23"”,
“status_code”: “R400”
}

The regex that i wrote in regex101 is this:
(?<=inferior to \\")\d+
The text where the number is is in a variable called jsonString. How to extract the needed number with the regex?

Hi @Povilas_Jonikas

You can use the below regular expression,

- Assign -> Output = System.Text.RegularExpressions.Regex.Match(Input.ToString,"(?<=inferior to\s+.*)\d+").Value

Note : Input is the string variable which contains the Input data.
Output is the String variable which used to store the output.

Check the below image for better understanding,

Hope it helps!!

1 Like

ideally we would combine JSON processing and Regex

Have a look here:

From Regex101

1 Like

Use the assign activity and write the regex expression there as below

- Assign -> Output = System.Text.RegularExpressions.Regex.Match(Input.ToString,"(?<=inferior to\s+.*)\d+").Value

Note : Input is the string variable which contains the Input data.
Output is the String variable which used to store the output.

1 Like

Yes, sorry, didint see this at first. Thanks to both of you, it works :slight_smile:

1 Like

It’s my pleasure @Povilas_Jonikas

Happy Automation!!

1 Like

Visualizing the above:
grafik

keep in mind the illustration of " with "" within the immediate panel

1 Like

One more thing. Is it possible to get the “23” as int32?

Bassically the number is going to be used for how many times i need to loop a specific set of activities

grafik

1 Like

Ur a beast, thanks a lot :innocent:

Yes you can do it the output variable should be int32 datatype and use the below expression by using CInt function.

- Assign -> Output = Cint(System.Text.RegularExpressions.Regex.Match(Input.ToString,"(?<=inferior to\s+.*)\d+").Value)
1 Like

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