regexes can be in a number of ways. one, is the familiar /regex/flags. Another, is with the m// operator, which can have any thing instead of the "/". I think there are some other ways as well, but those are not matched by this regex.$constraint =~ m@ ^\s* # skip all whitespace at beginning ( /.+/ # capture the custom regex |m(.).+\2 # does this capture the ops? What does the |m do? +why is the (.) and \2 in there? ) [cgimosx]* # ?? don't understand what this is for. what are we t +rying to match? I thought the ops were matched above \s*$ # skip all whitespace at end @x
the m(.).+\2 part of the regex is for matching m// type regexes. it says "Match an 'm', followed by any character (the delimiter), followed by at least one character (the regex itself), until you reach the delimiter again". a "\2" is a of using backreferences in regexes. It matches "whatever was in the 2nd set of ()s".
See man perlop for more details.
-- Dan
In reply to Re: A Regex to identify Regex's / Compiling a regex
by zigdon
in thread A Regex to identify Regex's / Compiling a regex
by knowmad
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |