It is working, but how? I'm sure match should start with 'm' letter if delimiter is not '/', but this '?' clearly is not delimiter. It is not assertion as well because assertion starts with '?<='. Looks like '<' is just part of pattern searching for '<LOGIN' (with optional white characters). '?' is special character and perl should give me some syntax error like:# Find LOGIN tag. if ((($ln =~ ?<[ ]*LOGIN[ ]?) || ($ln =~ ?<[ ]*LOGIN$?)) && ($pword) && ($uname)) { ... }
and yet it just works. Deparse does not give any clue:C:\>perl -e "/?/" Quantifier follows nothing in regex; marked by <-- HERE in m/? <-- HER +E / at -e line 1.
neither does Regex::Explain:# perl -MO=Deparse -e '$ln=" < LOGIN > "; $ln =~ ?<[ ]*LOGIN[ ]?' $ln = ' < LOGIN > '; $ln =~ ?<[ ]*LOGIN[ ]?; -e syntax OK
Perl version is 5.8.8 on Linux and 5.14.2 on Windows.C:\>perl -e "use YAPE::Regex::Explain; $REx = '?<[ ]*LOGIN[ ]?'; print + $exp = YAPE::Regex::Explain->new($REx)->explain" The regular expression: matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- C:\>perl -e "use YAPE::Regex::Explain; $REx = qr/?<[ ]*LOGIN[ ]?/; pri +nt $exp = YAPE::Regex::Explain->new($REx)->explain" Quantifier follows nothing in regex; marked by <-- HERE in m/? <-- HER +E <[ ]*LOGIN[ ]?/ at -e line 1.
In reply to mysterious regexp syntax by grizzley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |