正则表达式,用于在数字前后添加字符

Mik*_*ike 10 regex expression numbers character notepad++

我有一个方括号之间的数字列表,我需要在确切的数字之前和之后添加单词(即保持相同的数字).我使用notepad ++替换,但如果你有其他程序的解决方案,请告知.

例:

text [121] othertext
moretext [16] othertextmore
andtext [5940] othertextplus
Run Code Online (Sandbox Code Playgroud)

结果:

text xxxxxxxxx [121] xxxxxxxxx othertext
moretext xxxxxxxxx [16] xxxxxxxxx othertextmore
andtext xxxxxxxxx [5940] xxxxxxxxx othertextplus
Run Code Online (Sandbox Code Playgroud)

这些数字当然是\d+但我想告诉它在看时保持相同的数字.

man*_*lds 22

找什么: (\[\d+])

用...来代替: xxxxxxxxx \1 xxxxxxxxx

在此输入图像描述


小智 5

正则表达式:

Find regex = \[\d+\]
Replace regex = xxxxxxxxx$&xxxxxxxxx
Run Code Online (Sandbox Code Playgroud)


参考:正则表达式