保存的图案后立即替换数字 [英] Replacing digits immediately after a saved pattern
问题描述
搜索的模式类似于text9
我搜索(text)9
我想用\15
代替,这样我会得到text5
,但是它只是给了我text
.
I want to replace with \15
so that I would get text5
but instead it's just giving me text
.
除数字外,其他任何字符都有效.
Any other character works except for digits.
推荐答案
事实证明,PCRE样式的反向引用不起作用.
As it turns out, the PCRE-style back-references do not work.
因此,您必须使用\015
替换为第一个捕获组(\01
)和5
捕获的文本.
So, you have to use \015
to replace with the text captured with the first capturing group (\01
) and 5
.
由于不能有超过99个捕获组,并且\
之后的两个数字都被当作后向参考组号,因此\01
被解释为对第一个组的参考,其余为文字数字.
Since there cannot be more than 99 capturing groups, and both the digits after \
are treated as back-reference group number, \01
is interpreted as the reference to the first group, and the rest are literal digits.
这篇关于保存的图案后立即替换数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!