Klara
March 20, 2019, 9:42am
1
Hi!
I am working with a regex code which is collecting a String of 12 numbers from a textvariable between 0-9. The code I have is this:
System.Text.RegularExpressions.Regex.Match(textVariable, “[0-9]{12}”).Value
I would like to add the or-operator (||) in this expression due to that sometimes the structure of the numbers differs. The two scenarios is:
xxxxxxxxxxxx (12 numbers in a regular sequence)
xxxxxxxx-xxxx (12 numbers with the character “-” before the last four numbers)
Is this possible, and how should I add this scenario to the existing example above.
Thanks!
/Klara
lakshman
(Ganta lakshman)
March 20, 2019, 9:44am
2
@Klara ,
First replace that ‘-’.
textVariable.replace(“-”,“”). . Then apply regular expression.
1 Like
Klara
March 20, 2019, 10:08am
3
@lakshman Thank you, that was very helpful!
I have another question for you if you would like to assist.
The next step is to get some information between these numbers and a line break.
Something like this:
System.Text.RegularExpressions.Regex.Match(textVariable,“((?<=Linebreak).*(?=, “+theNumbers+”))”).Value
Thank you!
/Klara
1 Like
system
(system)
Closed
March 23, 2019, 10:08am
4
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.