in reply to Re: /x modifier with \Q and \E
in thread /x modifier with \Q and \E

Thanks parv - I thought I'd try the regex debugger too just before I posted the message. I saw that it was trying to anchor ' ++ ', which prompted my question at the end of the original post. It surprised me and I thought I'd lost the plot somewhere along the line.

I wanted to make it possible for my script to handle special regex characters (like the +) so at this point, I think I'll just write cluttered regex's unless someone can point out how to do it :-)

Thanks

Replies are listed 'Best First'.
Re^3: /x modifier with \Q and \E
by parv (Parson) on Apr 01, 2008 at 05:54 UTC

    I suppose you are aware of quotemeta function, which you could use for the same effect of \Qpattern\E something like (one of many variations) ...

    my @patterns = map { quotemeta $_ } @string

    In any case, as the Gory details says, be aware of what happens with [$@] in \Q (or quotemeta) including other meta characters.

      Brilliant. I was aware of quotemeta but I had totally forgotten. I was even considering writing my own version :-(

      Thanks for the help - that's what I'll use.