EgyEast
EgyEast

Reputation: 1572

What is the C# regex format to match +- signs or space?

I've writing code using Regex format to search for numbers that has signs before it either: + , - or space like the following numbers :

(+02.00)
(-03.50)
( 00.00)

I'm using this format but i want to include space with +-

[+-]\d{2}.\d{2}

Please help , thanks.

Upvotes: 1

Views: 98

Answers (1)

anubhava
anubhava

Reputation: 785146

You can use:

[+\s-]\d{2}\.\d{2}
  • Take note of \s in the first character class [...] that will match a whitespace.
  • Unescaped hyphen should be at first or last position in character class.
  • Also, you need to escape the dot otherwise it will match any character.

Upvotes: 1

Related Questions