使用“在嵌入 XML 的正则表达式中
目前我正在尝试在 ant 任务中使用 sed 将字符序列 \" 替换为 " 。 我成功地将序列 \= 替换为 = 但它对 " 不起作用,因为无论我如何转义该字符,参数都会结束。 这是我用于 \= 的代码:
<exec command="sed" input="${inputfile}" output="${outputfile}">
<arg value="-e"/>
<arg value="s|\\=|=|g"/>
</exec>
我怎样才能让它工作?引用的正确转义是什么?非常感谢任何帮助!谢谢!
Currently I'm trying to replace the character sequence \" with " using sed in an ant task.
I successfully replaced the sequence \= with = but it just won't work for " because the parameter would end, no matter how much I escape the character.
This is the code I'm using for \=:
<exec command="sed" input="${inputfile}" output="${outputfile}">
<arg value="-e"/>
<arg value="s|\\=|=|g"/>
</exec>
How can I get this working? What is the right escape for a quote? Any help is very much appreciated! thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用
"
,它是 XML 中双引号的实体。Try using
"
which is the entity for double-quotes in XML.看起来你正在写XHTML。您不能通过在 XHTML 中编写
\"
来转义"
,而是使用"
。此类“转义符”的完整列表(它们实际上不是转义符,它们是字符实体)可以在这里找到:http://www.w3schools.com/tags/ref_entities.aspIt seems that you are writing XHTML. You don't escape
"
by writing\"
in XHTML, but with"
. A full list of such "escapes" (they aren't escapes really, they are character entities) can be found here: http://www.w3schools.com/tags/ref_entities.asp