I'm trying to find a way to trap bad item numbers. I want to parse the parameter "itemid=" and then everything up to either an "&" or end-of-string. A good item number will contain only ASCII letters, numbers, dashes, and underscores and may terminate with a "&" or it may not (see samples below). The following string should test negative in the regex below:
my $QUERY_STRING = 'itemid=AT18C&i_AT18C=1'; but a string containing "itemid=AT18/C" should test positive, since it has a slash. I can catch a single bad character and get it to work, e.g. if ( $QUERY_STRING =~ m| itemid= .*? [/]+? .*? &? |x ) { but I'd like to do something like this instead to catch others: if ( $QUERY_STRING =~ m| itemid= (?: .*? [^a-zA-Z0_-]+ .*? ) &? |x ) { ... Unfortunately, I can't get it to work. I've read perlretut, but can't see the answer. What am I doing wrong? Thanks, Frank Here are a couple of test strings: 'itemid=AT18C&i_AT18C=1&t=main.htm&storeid=1&cols=1&c=detail.htm&ordering=asc' 'c=detail.htm&itemid=AT18C' -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/