regex repetition



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 to check to make sure they input a valid list that
i can process:
###########
foreach ($temp2 = <>) {

$list1 = $temp2;

if ($list1 =~ /(\s*\d+;)+/g || $list1 =~ /(\s*\d+;)+/g ) {

print "yay\n";
}else {print "boo\n";};

#print "...",$list1, "...\n";

}
###########

which doesn't work, because as soon as it matches the first time,
anything goes. How do i get it check for repetition, even though i
don't know how many repetitions there will be. there could be
1,2,3,5, even 10 groupings.

so the pattern isns't hard, there has to be a number, then either a
'-' or s ';', then repeat or not. the only special case is the first
one which could just be a single number, or a number '-'number. I
just don't know how to implement it.

(#(-||;))(#(-||;))(#(-||;))


thanks, ryan
.



Relevant Pages

  • Re: Halo 3 a disappointment so far
    ... was doing was taking out a bunch of flying Brutes on board some giant ... those floating tanks for the first time was annoying because there ... a decent game but it's nowhere near as interesting as the previous two ...
    (alt.games.video.xbox)
  • Re: Halo 3 a disappointment so far
    ... was doing was taking out a bunch of flying Brutes on board some giant ... those floating tanks for the first time was annoying because there ... games over the course of the past 2 years. ...
    (alt.games.video.xbox)
  • Re: Halo 3 a disappointment so far
    ... was doing was taking out a bunch of flying Brutes on board some giant ... those floating tanks for the first time was annoying because there ... games over the course of the past 2 years. ...
    (alt.games.video.xbox)
  • Re: First time ever pissed walking out of GC (And something on attaching guitar to computer)
    ... Tell them they're a bunch of pillowbiters. ... short story long - my first time OS and his first time trying to understand Australian accents. ...
    (alt.guitar)
  • Re: to DRA
    ... New Orleans parade with with a bunch of drunken Irishmen. ... first time anyone had seen a banjoist march. ... Free download of technical exercises worth a lifetime of practice: ...
    (rec.music.classical.guitar)

Loading