[Cialug] OT: can somebody help me with a regular expression?
Chris Freeman
cwfreeman at gmail.com
Fri Jul 25 22:38:03 CDT 2008
Yes, (|D|PP) is nothing, 'D', or 'PP'.
I'm not sure what zero you're referring to, though. I didn't post it, but
'0' and 'D0' and 'PP0' match.
The basics are:
match a leading nothing, 'D' or 'PP', followed by between 1 and 3 digits,
followed by zero or more sets of three digits with an optional leading
comma.
I just realized there's a slight problem with this: '1,234567' will match,
which isn't ideal. You'll have to decide if that's significant. If so, split
it into two regexes, one with commas and one without. Otherwise, you could
do this (not recommended due to obtuseness):
(\s|^)(|D|PP)\d{1,3}(,(\d{1,3}(,\d{1,3})*)|(\d{1,3})*)(\s|$)
This will match '12,345,678' and '12345678', but not '12,345678'.
Chris
On Fri, Jul 25, 2008 at 10:23 PM, Nathan C. Smith <nathan.smith at ipmvs.com>wrote:
> Is this- (|D|PP) Nothing, or D or PP ? Interesting.
>
> Yeah, 0 probably should be a possibility.
>
> Thank-you for your help with this little puzzle.
>
> -Nate
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cialug.org/pipermail/cialug/attachments/20080725/0ad112b3/attachment.html
More information about the Cialug
mailing list