$constraint =~ m@ ^\s* # skip all whitespace at beginning ( # start capturing /.+/ # match a '/' any number of anychar '/' | # or m # char 'm' (start of a match) (.) # capture the delimiter .+ # skip all the stuff \2 # upto the second occurance of the delimiter ) #end capture [cgimosx]* # match zero or more match options \s*$ # skip white space @x