正则表达式在数字之前和之后添加字符 [英] regular expression to add characters before and after numbers
本文介绍了正则表达式在数字之前和之后添加字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个方括号之间的数字列表,我需要在确切数字之前和之后添加字词(即保持相同的数字)。我使用notepad ++替换,但如果你有一个解决方案与其他程序,请指教。
例如:
text [121] othertext
moretext [16] othertextmore
andtext [5940] othertextplus
结果:
text xxxxxxxxx [121] xxxxxxxxx othertext
moretext xxxxxxxxx [16] xxxxxxxxx othertextmore
andtext xxxxxxxxx [5940] xxxxxxxxx othertextplus
\d +
但我想告诉它在查找时保持相同的数字。解决方案查找内容:
(\ [\d +])
c $ c> xxxxxxxxx \1 xxxxxxxxx
I have a list of numbers between square brackets, and I need to add words before and after the exact numbers (i.e. keep the same numbers). I use notepad++ to replace, but if you have a solution with other program please advise.
Example:
text [121] othertext moretext [16] othertextmore andtext [5940] othertextplus
outcome:
text xxxxxxxxx [121] xxxxxxxxx othertext moretext xxxxxxxxx [16] xxxxxxxxx othertextmore andtext xxxxxxxxx [5940] xxxxxxxxx othertextplus
The numbers are of course
\d+
but I want to tell it to keep the same numbers when looking.解决方案Find What:
(\[\d+])
Replace With:
xxxxxxxxx \1 xxxxxxxxx
这篇关于正则表达式在数字之前和之后添加字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文