[英]backslashes in perl substitution
I'm trying my luck with a perl one-liner changing some commands in a bunch of .tex files. 我正在尝试用perl单行代码更改一堆.tex文件中的某些命令的运气。 I got as far as the following: 我得到以下信息:
perl -pi -e "s/\Q\linenum{some more stuff}\E/\Q\uln\E/g" *tex
Which results in \\lLn
instead of the expected replacement patter \\uln\u003c/code> .
结果为
\\lLn
而不是预期的替换模式\\uln\u003c/code> 。
Apparently while
\\Q
and \\E
take care of other special characters, they don't take care of the \\l
\\u\u003c/code> changing the case of the next character, how would I do that?
显然,虽然
\\Q
和\\E
照顾其他特殊字符,但他们却不照顾\\l
\\u\u003c/code>改变下一个字符的大小写,我该怎么办?
\\Q\\E
works best for \\Q$var\\E
. \\Q\\E
最适合\\Q$var\\E
Elsewhere, you can use \\
to escape characters that need escaping. 在其他地方,可以使用\\
来转义需要转义的字符。
perl -i -pe's/\\linenum\{some more stuff\}/\\uln/g' *tex
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.