in reply to Re: followup on regex
in thread followup on regex

The output of "perldoc perlre" (or "man perlre" on unix) is lengthy (and rather dense in spots), but well worth whatever time you can devote to read and understand it. It will explain the syntax: what the square brackets mean inside a regex, why the positioning of a hyphen inside square brackets is very important, when you need to use a backslash to "escape" a character (in square brackets or elsewhere in the regex), and when you don't need to use it.

For parts that seem hard to decipher, play with the examples that are provided; try variations on the examples to see what happens; perl one-liners on a command line are very handy for this:

perl -e '$_ = "test-string"; print "okay\n" if (/[-st]{5}/)' # that should print "okay" perl -e '$_ = "test-string"; print "okay\n" if (/[s\-t]{5}/)' # should do the same perl -e '$_ = "test-string"; print "okay\n" if (/[s-t]{5}/)' # prints nothing: regex didn't match perl -e '$_ = "test-string"; print "okay\n" if (/[t-s]{5}/)' # prints an error message: "Invalid [] range "t-s" in regex...
... and so on. It all makes sense when you RTFM.