Hello,
I need help in building a regex. My initial string message looks like this:
I need a bool regex that should be true if the 1st word is a number, or a combination of numbers devided by “-” character.
So if i run I expect to have the values of 1 and 1-2 as outputs from my example variable
So far I came up with this one that works but if my first word is “12word” then the output will be 12word and i want it to be just 12.
Thank you!
HI @Paul_Andrei_Turcu
Check with this
For Boolean
(Single digit)
System.Text.RegularExpressions.Regex.IsMatch(stringVar,“^\d+")
(Digits divided by “-”)
System.Text.RegularExpressions.Regex.IsMatch(stringVar,“\d±\d+")
For getting values
(Single digit)
System.Text.RegularExpressions.Regex.Match(stringVar,“^\d+").Tostring
(Digits divided by “-”)
System.Text.RegularExpressions.Regex.Match(stringVar,“\d±\d+").ToString
Regards
Sudharsan
Gokul001
(Gokul Balaji)
October 6, 2022, 6:13am
4
Hi @Paul_Andrei_Turcu
You can try with this expression to get 12
YourString = “1 word 1 word2”
System.Text.RegularExpressions.Regex.Replace(YourString,"word|^\d|\s","").Tostring.Trim
Regards
Gokul
Hi @Paul_Andrei_Turcu ,
I am attaching a sample workflow for your reference which might help you to get your desired output. Please look into the below code.
Sequence1.xaml (6.1 KB)
Also sending screenshot of all matched formats.
Thanks & Regards,
Shubham Dutta
1 Like
Thank you but seems that i cant understand.
“word” word is just an example not an anchor based word in my example
If my string input is like
“1 have a nice day” => “1”
“1-2 have a nice day” => “1-2”
“1have a nice day” => “1”
“1-2have a nice day” =>“1-2”
The ideea is to treat the chase of not having a space and as a general rule, my number or combo of numbers are allways at the start of my string var.
You can try with the expression i sent you @Paul_Andrei_Turcu
Gokul001
(Gokul Balaji)
October 6, 2022, 6:32am
9
HI @Paul_Andrei_Turcu
How about this expression
System.Text.RegularExpressions.Regex.Match(YourString,"\d.\d|^\d+").Tostring
Regards
gokul
Hi @Paul_Andrei_Turcu ,
If you got your desired output and have no further queries.please mark the solution and close the thread.
Thanks & Regards,
Shubham Dutta
Thank you all, both ideas of Shubham and Gokul works for me but i cant mark 2 solutions xD
system
(system)
Closed
October 9, 2022, 6:53am
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.