perl - 转义 > 字符

标签 perl escaping character

我有一个文本文件,其内容是<rapidwizloc oa_var="s_rapidwizloc">C:\temp</rapidwizloc>
我想要值 C:\temp替换为从变量定义的不同值

此外,将从批处理文件(windows .cmd)中调用 perl oneliner

set CMDDIR=C:temp1
set str1=C:temp
echo %CMDDIR%
echo %str1%
perl -pi.bak -e "s/s_rapidwizloc\"\>%str1%/s_rapidwizloc\"\>%CMDDIR%/g" a.txt
运行 .cmd 时我得到

The filename, directory name, or volume label syntax is incorrect.

最佳答案

逃离> Windows 批处理文件中的字符,使用抑扬符,因此 ^> .

关于perl - 转义 > 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18283742/

相关文章:

linux - linux中符号^\是什么意思

python - 文字识别。字符分割阶段

swift - 如何在 Swift 中生成一个随机的 unicode 字符?

regex - 如何从 C 源文件中删除所有/* */注释?

windows - 如何将 perl 脚本中设置的环境变量导出到批处理 shell?

perl - Perl 5 中的哈希随机化

perl - 如何访问 If/else 范围之外的值

escaping - 使用 trans 翻译单引号

sql-server - 在姓氏搜索中添加撇号

c++ - "cout"无法使用汉字