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...