Dimi Dimi - 1 year ago 58
C# Question

Regex to detect numbers only between special characters

I need Regex to detect numbers only between special characters.




My objective is to get this string


Answer Source

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


C# declaration:

string pattern = @";\d+=\d+\?";

See the regex demo


  • ; - a semi-colon
  • \d+ - 1 or more digits
  • = - an equal sign
  • \d+ - 1 or more digits
  • \? - a literal ? char

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download