简体   繁体   English

正则表达式搜索并替换崇高文本xml中的单个空格

[英]regex search and replace for single space in sublime text xml

I am in Sublime Text 2, trying to replace single spaces within all nodes of an xml doc, so that instances like this: 我在Sublime Text 2中,尝试替换xml文档的所有节点内的单个空格,以使实例如下所示:

<img>my image title.png</img>

will become 会变成

<img>my%20image%20title.png</img>

based on looking around for a while, what I am trying is 基于环顾了一会,我正在尝试的是

/(<img>[^ <]*) /\1%20/

Which is not working. 这不起作用。 ANy idea what I am doing wrong? 知道我在做什么错吗?

Thanks in advance! 提前致谢!

In Sublime Text 2 this pattern should work for <img>my image title.png</img> or similar: Sublime Text 2中,此模式适用于<img>my image title.png</img>或类似的图片:

Find: (?=</img>|<img>|.)\\s 查找: (?=</img>|<img>|.)\\s

Replace: %20 更换: %20

Result: <img>my%20image%20title.png</img> 结果: <img>my%20image%20title.png</img>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM