问题描述
使用
< replaceregexp署名=真正的标志=G文件=$ {} someFIle
匹配=[\\\\]
替换=//>
我可以很容易地替换所有/.
但
假设文字是:
其他A \\ B \\ C
某些C \\ D \\ E
其他...
其他...
...
如何使用替代\\/,其中有preFIX第二行一些,而不是其他行:
其他A \\ B \\ C
一些C / D / E
...
您问题不能仅仅通过单一的正则表达式解决。你需要做更复杂的东西。
1)只用指定的preFIX读取属性,并将其保存到变量。这可以用propertyregex进行。
2),阅读所有其他属性并保存它们的地方。
3)更换\\不管你在其中包含preFIX属性想要的。
4)写与没有preFIX的属性修改的属性到一个文件替换原始文件。
5)享受: - )
尝试一个做这些步骤之一。如果你还有问题,让我知道。
Using
<replaceregexp byline="true" flags="g" file="${someFIle}"
match = "[\\]"
replace = "/"/>
I can easily replace all the \ with /.
But
Suppose the text is:
Other A\B\C
Some C\D\E
Other ...
Other ...
...
How to replace the "\" with "/" in the second line which has prefix "Some", but not other lines:
Other A\B\C
Some C/D/E
...
Your problem cannot be merely solved by a single regex. You need to do something more complex.
1) Read properties only with the specified prefix and save them to variable. This can be done with propertyregex.
2) Read all other properties and save them somewhere.
3) Replace \ with whatever you want in the properties which contain the prefix.
4) Write the modified properties with the properties without the prefix into a file replacing the original file.
5) Enjoy :-)
Try to do these steps one by one. If you still have questions let me know.
这篇关于如何更换一个反斜杠在蚂蚁一个几行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!