Reply to Re: Regular expression

Your name:

Reply:


Posted by AnrDaemon on 10/21/07 11:08

Greetings, Steve.
In reply to Your message dated Friday, October 19, 2007, 23:10:56,


>> dgc> I need a regular expression that validate a list of numbers separated
>> dgc> by "-" , numbers can not be greater than 999
>>
>>
>> dgc> Valid examples
>> dgc> 0
>> dgc> 12-455-01
>> dgc> 1-9
>> dgc> 125-32-155-45-45
>>
>> dgc> Invalid examples
>> dgc> -1
>> dgc> 45-
>> dgc> 1-45665456-4
>> dgc> 12-45-
>> dgc> -
>>
>> dgc> Thanks ;)
>>
>> Perl one:
>> ^\d{1,3}(\-\d{1,3})*$

S> wow...thanks for that! it wasn't like that was posted in two newsgroups 4
S> days ago or anything...in the exact form of:

S> /^\d{1,3}(?:-\d{1,3})*$/

Only difference is post-processing of result produced by this RE.
In my form You'll get set of subpatterns, in the form You referred above
You'll get only fullstring match and no subpatterns.
"(?: ... )" construction means grouping without storing, useful for in-line
multiplication of patterns.

S> i suppose i should just wait till someone else answers a post and a couple
S> of days later, post the exact freaking thing. the redundancy, i think, would
S> just ensure that the op reeeeealy gets it.

:) It was taking me longer than 2 months trying to figure out, how RE works
exactly and can it be used in real life. But after that, I can't live without
it.


--
Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация