Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: regular expression with @@/

by JadeNB (Chaplain)
on Dec 11, 2009 at 09:49 UTC ( #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
Node Status?
node history
Node Type: note [id://812353]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2021-05-12 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (124 votes). Check out past polls.

    Notices?