Re: regex repetition

2006-07-13 Thread Dr.Ruud
"Mumia W." schreef: > Dr.Ruud: >> Mumia W.: >>> $str =~ m/^((\d+-\d+|\d+);?)+$/g; >>> >>> However, this does not consider 250-100 to be invalid. >> >> Nor "10-30-20". >> >> What's the g-modifier for? >> >> The structure is 'a;b;c;d', the smallest is 'a', so treat the ';' as >> the start of a

Re: regex repetition

2006-07-13 Thread Mumia W.
On 07/13/2006 12:47 AM, Dr.Ruud wrote: "Mumia W." schreef: Ryan Moszynski: I need to write some code to allow users to specify which of a whole bunch of elements(e.g.512/1024) that they want to view. My idea for how to do this was to have them input a semicolon delimited list, for example:

Re: regex repetition

2006-07-13 Thread Mumia W.
On 07/13/2006 12:47 AM, Dr.Ruud wrote: "Mumia W." schreef: $str =~ m/^((\d+-\d+|\d+);?)+$/g; However, this does not consider 250-100 to be invalid. Nor "10-30-20". What's the g-modifier for? The structure is 'a;b;c;d', the smallest is 'a', so treat the ';' as the start of a trailer.

Re: regex repetition

2006-07-12 Thread Dr.Ruud
"Mumia W." schreef: > Ryan Moszynski: >> I need to write some code to allow users to specify which of a whole >> bunch of elements(e.g.512/1024) that they want to view. My idea for >> how to do this was to have them input a semicolon delimited list, for >> example: >> >> 1-10;25;33;100-250 >> >>

Re: regex repetition

2006-07-12 Thread Mumia W.
On 07/12/2006 05:08 PM, Ryan Moszynski wrote: I need to write some code to allow users to specify which of a whole bunch of elements(e.g.512/1024) that they want to view. My idea for how to do this was to have them input a semicolon delimited list, for example: 1-10;25;33;100-250 i tried usin

Re: regex repetition

2006-07-12 Thread Aaron Priven
Check out the module Set::IntSpan and see if it does what you want. http://search.cpan.org/dist/Set-IntSpan/IntSpan.pm On Jul 12, 2006, at 3:08 PM, Ryan Moszynski wrote: I need to write some code to allow users to specify which of a whole bunch of elements(e.g.512/1024) that they want to view.

Re: regex repetition

2006-07-12 Thread Dr.Ruud
"Ryan Moszynski" schreef: > 1-10;25;33;100-250 echo '1-10;25;33;100-250' | perl -nle ' /\A\d+(?:-\d+)?(?:;\d+(?:-\d+)?)*\z/ and print "$_ =OK" ' But that also matches '12-3'. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-

Re: regex repetition

2006-07-12 Thread John W. Krahn
Ryan Moszynski wrote: > I need to write some code to allow users to specify which of a whole > bunch of elements(e.g.512/1024) that they want to view. My idea for > how to do this was to have them input a semicolon delimited list, for > example: > > 1-10;25;33;100-250 > > > i tried using this t

Re: regex repetition

2006-07-12 Thread Rob Dixon
Ryan Moszynski wrote: > > I need to write some code to allow users to specify which of a whole > bunch of elements(e.g.512/1024) that they want to view. My idea for > how to do this was to have them input a semicolon delimited list, for > example: > > 1-10;25;33;100-250 > > > i tried using this t

RE: regex repetition

2006-07-12 Thread Timothy Johnson
Why not just use split()? Then you can do a simple regex on each element: ### use strict; use warnings; my $string = '1-10;25;33;1-00-250'; my @array = split(/;/,$string); foreach my $element(@array){ if($element =~ /^\d+-?\d*?$/){ print "$element => valid\n";

Re: regex repetition

2006-07-12 Thread Mr. Shawn H. Corey
Ryan Moszynski wrote: > I need to write some code to allow users to specify which of a whole > bunch of elements(e.g.512/1024) that they want to view. My idea for > how to do this was to have them input a semicolon delimited list, for > example: > > 1-10;25;33;100-250 You will need more than a r