[Israel.pm] RegEx question

Yitzchak Scott-Thoennes sthoenna at efn.org
Tue Jan 8 11:35:02 PST 2008


On Tue, January 8, 2008 6:18 am, Yossi Itzkovich wrote:
> I need to build a regex to validate a list of number or ranges, such as
> in giving when sending to printing, for exmaple:
>
> 1,4,6-9,13-15,19
>
>
> Is there a way to do it in one regex ?

But of course:

/^(?:(?:(\d+)-(?=(\d+)(??{$1 >= $2 &&
"(?!)"})))?(\d+)(?:\z|,(?=(\d+)(??{$3 >= $4 && "(?!)"}))))+\z/





More information about the Perl mailing list