Reputation: 37633
I need Regex to detect numbers only between special characters.
Pattern ;\d+=\d+?
String 0014;5010730101000033347=4510120173?AA
My objective is to get this string
;5010730101000033347=4510120173?
Upvotes: 2
Views: 145
Reputation: 626870
The \d+?
at the end of the pattern matches 1 digit, no more, due to the +?
lazy quantifier matching 1 or more occurrences, but as few as necessary to return a valid match.
You may use
;\d+=\d+\?
^^
C# declaration:
string pattern = @";\d+=\d+\?";
See the regex demo
Details:
;
- a semi-colon\d+
- 1 or more digits=
- an equal sign\d+
- 1 or more digits\?
- a literal ?
charUpvotes: 4