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

Re^4: Escape special characters for a LaTeX file

by Laurent_R (Canon)
on Dec 14, 2014 at 17:08 UTC ( [id://1110319]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Escape special characters for a LaTeX file
in thread Escape special characters for a LaTeX file

Try to use the quotemeta operator (or, equivalently, the \Q ... \E tags) on your search list. It should remove all problems of this sort.

Replies are listed 'Best First'.
Re^5: Escape special characters for a LaTeX file
by AnomalousMonk (Archbishop) on Dec 16, 2014 at 03:59 UTC

    Another way to completely defeat scalar or array interpolation in regexes (as in strings) is by use of  ' (single-quote) delimiters for the  s/// substitution:

    c:\@Work\Perl\monks\marek1703>perl -wMstrict -le "my $s = '-#-$-%-&-~-_-}-{-^-0-$%&~_}{^0'; print qq{'$s'}; ;; $s =~ s' (?= [#$%&~_{}^]) '\\'xmsg; print qq{'$s'}; " '-#-$-%-&-~-_-}-{-^-0-$%&~_}{^0' '-\#-\$-\%-\&-\~-\_-\}-\{-\^-0-\$\%\&\~\_\}\{\^0'
    (This applies also to  m// and  qr// operators.) See perlop.

      Interesting, I did not know that.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-26 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found