[ACCEPTED]-Need a regex to match a variable length string of numbers that can't be all zeros-negative-lookahead
Accepted answer
^(?!0+$)\d{1,19}$
0
Just do a negative lookahead:
(?!^0+$)(^\d{1,19})
This works 1 fine in Perl.
(?!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.
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
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.