Itniv Itniv - 6 months ago 68
C# Question

Regex for 550-5.1.1 c#

How do I write a Regex for this format "550-5.1.1"
Update : I thought my question was clear, still making it more elaborate

I need to write a Regex for accepting 3 integers then a '-' and 1 integer then a '.' and 1 integer then a '.' and 1 integer


WWW 3 digit integer,
X 1 digit integer,
Y 1 digit integer
Z 1 digit integer


If you are suggesting that you will always have 3 digits, a dash and then always 1 digit from then on, this will work


if you will have, say, 1 to 4 in the first section you can have this


as you seem new to Regex, here's an explanation

^ - start of the string
\d - a digit
{3} - exactly three of the preceding object
- A literal dash character
\. - an escaped '.' character, as . unescaped can match any character.
$ - end of the string