Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: regular expression with @@/

by JadeNB (Chaplain)
on Dec 11, 2009 at 09:49 UTC ( [id://812353]=note: print w/replies, xml ) Need Help??


in reply to regular expression with @@/

I think your (very interesting!) problem has been solved several times already—the main points being that
  • you don't need to escape @@ in the regex (but would need to if it were followed by some alphabetic character);
  • if you did, then \Q usually wouldn't do it (but seems to do it in this case, because there's no interpolation going on), but single-quote delimiters instead of ' would;
  • and, anyway,
  • probably the problem is that your input doesn't actually contain @@ as you think it does (for example, "a@@b" is actually a@ concatenated with the stringification of @b)
—so I'll just point out one thing that no one seems to have mentioned, which is that \Q/\E are a pair, and must should be used as such. Your sample code has only a \Q, although Perl seems forgivingly to assume the \E:
$ perl -E 'say my $rx = qr|\A(.+)\Q@@/|;' (?-xism:\A(.+)\@\@\/)
You may also be interested in the function, quotemeta, underlying the escape, which works fine on @.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://812353]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-19 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found