Paddi
April 25, 2023, 6:25am
1
Hi all,
I’m currently working on an issue, which needs to get specific number in a string.
The string would be like: overall 54 records, 3 pages in total.
I need to get the “3” out of this sentence. However this expression is not working: integer.parse(right(“page”,5))
Do you know how to deal with this issue? Thanks a lot.
Anil_G
(Anil Gorthi)
April 25, 2023, 6:28am
2
@Paddi
You can try this
\d+(?= pages)
System.Text.RegularExpressions.Regex.Match(str,"\d+(?= pages)").Value
cheers
1 Like
Hi
Hope the below expression would help you resolve this
Use a assign activity like this
Str_value = System.Text.RegularExpressions.Regex.Match(str,”\d+(?=\spages|pages)”).Value
Where str_value is a string variable
The reason why ur expression was not working is
this expression attempts to extract the rightmost 5 characters of the string “page” (which will be “page” itself), and then convert them to an integer. Since “page” cannot be parsed as an integer, this expression will throw a FormatException
at runtime.
Cheers @Paddi
1 Like
Jithesh_R
(Jithesh Karkera)
April 25, 2023, 6:44am
4
@Paddi ,
Split(Split("overall 54 records, 3 pages in total."," pages")(0),"records, ")(1)
Regards,
1 Like
Paddi
April 26, 2023, 3:53am
5
Hi @Palaniyappan ,
Really appreciate your answer, it’s working.
1 Like
Glad it got resolved @Paddi
system
(system)
Closed
April 29, 2023, 4:54am
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.