[ACCEPTED]-Need a regex to match a variable length string of numbers that can't be all zeros-negative-lookahead

Accepted answer
Score: 18

^(?!0+$)\d{1,19}$

0

Score: 2

Just do a negative lookahead:

(?!^0+$)(^\d{1,19})

This works 1 fine in Perl.

Score: 2

(?!0+$) is a lookahead directive. The ?! is 6 the negative lookahead command to search 5 for 1 or more 0's to the end of the string. If 4 that matches, then the characters are consumed, leaving 3 the regular digit search of \d{1,19}.

Boost Perl Regexp has 2 a good discussion of perl regexp as recognized 1 by Boost.

Score: 0

you don't need RegEx for that

            ulong test;
        string number = "1234567890123456789";
        if (ulong.TryParse(number, out test) && (test < 9999999999999999999ul) && (test > 0))
            Console.WriteLine(test);

0

More Related questions