in reply to Regex an Array?
Actually, re-reading the OP, i think your checked_ids is just a string. In that case,if( grep( $_ !~ /^\d+$/, @{$INPUT{'checked_ids'}) ){ # you have bad data }
Or could check the string for containing just numbers and commas, but the above methods will be preferred (this is less robust and harder to read):my @ids = split (/, +/, $INPUT{'checked_ids'}); # now check @ids w/grep() using the method above
note: not the only, or even best, way to write this regex, but what it's trying to do is match just on set of digits with possibly a comma-space after it.if( $INPUT{'checked_ids'} !~ /^(\d+(, +)?)+$/ ){ # you have bad data }
|
|---|