Hello,
I have a string like
1-38
I need to capture the “38”.
here is the assign:
Match = Regex.Match(“1-38”,“(?:\d+\s?-\s?)(.+)”)
but Match.Groups(0) returns 1-38 though when I test it in the configure regular expression, it does highlight 38 in yellow.
please help, thank you so much in advance
You can use simple split method @lynnsong986
varstring.split ("-"c)(1).tostring.trim
Cheers @lynnsong986
Jobin_Joy
(Jobin Joy)
December 8, 2021, 6:38pm
3
Hi @lynnsong986
If always length is 2 means you can use the below simply
Thank you.
Thanks to both, I’m asking the question because I want to know why that happens? I encountered similar problems with a lot more complicated text so I need to understand why.
Jobin_Joy
(Jobin Joy)
December 8, 2021, 6:44pm
5
The below one will help you to understand more about regular expression.
This CheatSheet introduces the basic use of regex functions. With further examples also special cases are presented.
Introduction
From the namespace System.Text.RegularExpressions following methods are offered:
Regex.Match
Regex.Matches
Regex.isMatch
Regex.Replace
Regex.Split
A simple usage for example would look like this:
[grafik]
Recommendation:
add System.Text.RegularExpressions to the imports:
[grafik]
it allows to use the shortened statement, as the namespace part can be ommited…
Thanks to @ppr
system
(system)
Closed
December 11, 2021, 6:45pm
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.