In article <09****************************@phx.gbl>,
"giulio santorini" <gi**************@yahoo.it> wrote:
Now I'am tring to build the second one but... it's quite
difficult.
Somebody could help me? This is what I've done:
^([1-9]{1}|[1-9]{1}[0-9]{1}|100)\.([0-9]{1}|[0-9]{2}|[0-9]
{3})$
But it doesn't work as I would... :-\
Tell us what you expect to happen, what actually happens, and why you
don't think that's right.
Give some examples of strings on which it should work but doesn't.
Give some examples of strings on which it shouldn't work but does.
All that aside, are you escaping the escape character--so that C#
doesn't digest your \ ? That is, you have the following, right?
^([1-9]{1}|[1-9]{1}[0-9]{1}|100)\\.( etc. )$
That is, \\. instead of \.
By the way, the {1} quantifiers are redundant. You could probably get
away with the following:
Regex r = new Regex("^([1-9][0-9]?|100)\\.([0-9]{1,3})$");
That regex looks for:
* the start of the string
then either
* one digit between 1 and 9
* and, optionally, one digit between 0 and 9
or
* the string 100
* a decimal point
* between one and three digits, each between 0 and 9
* the end of the string