Hello guys. I have sorted out a regex code to help me with the workflow, but cant seem to know how to use it
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?
mkankatala
(Mahesh Kankatala)
January 22, 2024, 2:30pm
2
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
ppr
(Peter Preuss)
January 22, 2024, 2:31pm
3
ideally we would combine JSON processing and Regex
Have a look here:
From Regex101
1 Like
mkankatala
(Mahesh Kankatala)
January 22, 2024, 2:35pm
5
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
1 Like
mkankatala
(Mahesh Kankatala)
January 22, 2024, 2:37pm
7
It’s my pleasure @Povilas_Jonikas
Happy Automation!!
1 Like
ppr
(Peter Preuss)
January 22, 2024, 2:37pm
8
Visualizing the above:
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
mkankatala
(Mahesh Kankatala)
January 22, 2024, 2:47pm
12
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
system
(system)
Closed
January 25, 2024, 2:47pm
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.