C
Captain Paralytic
I need to validate that a string meets the following criteria.
Is at least 1 digit > 0 (1-9)
May contain commas, hyphens and spaces
Must begin with a digit (1-9)
Must end with a digit (0-9)
Any new group of digits (either the first in the string or immediately
following a comma, space or hyphen) must begin with (1-9)
So:
good
1
123
1 456-567,676
bad
01
123,
,345
123 0456
123,345-087
I've come up with a couple of REGEXs but I'm no regexpert (geddit - I
know, no comedian either), but I'm sure there's a tidier way.
Is at least 1 digit > 0 (1-9)
May contain commas, hyphens and spaces
Must begin with a digit (1-9)
Must end with a digit (0-9)
Any new group of digits (either the first in the string or immediately
following a comma, space or hyphen) must begin with (1-9)
So:
good
1
123
1 456-567,676
bad
01
123,
,345
123 0456
123,345-087
I've come up with a couple of REGEXs but I'm no regexpert (geddit - I
know, no comedian either), but I'm sure there's a tidier way.