gwild — 2011-01-19T12:50:32-05:00 — #1
I need a regular expression which will require (anywhere in the input) at least 1 number, and the entire contents can also contain zero or more commas, apostrophes, and spaces.
The regular expression I've constructed is very close but does not quite work:
^[0-9, ][0-9][0-9, *]$
It will not accept, for example, input of a single digit, but it will accept something such as "2*".
How can I modify this to allow digits, commas, spaces, apostrophes, but also require at least 1 number?
Any help is appreciated.
paul_wilkins — 2011-01-19T13:34:30-05:00 — #2
The info about optional expressions will help here, where you use a question mark to indicate optional parts of the expression.
gwild — 2011-01-19T17:29:15-05:00 — #3
I'll review that material.
Thank you for the response.
logic_ali — 2011-01-19T21:20:05-05:00 — #4
The * inside the  includes it as an acceptable character, just put it after.
For me it's less ambiguous to use \s for spaces. The same for comma and apostrophe which don't actually need to be escaped.
gwild — 2011-01-20T08:33:00-05:00 — #5
That appears to have remedied the issue. Thanks.
I will, of course, make use of the information at the link provided by PMW57.