【发布时间】:2020-03-19 11:21:01
【问题描述】:
我想将一个字符替换为另一个字符,该字符位于字符串中的特定位置。 示例:
This is a test string! Now comes a different one! And yet an another one to demonstrate what I want! Hello there! How can I achieve to replace all exclamation mark to point!
我知道我的角色在 21st 位置,因此我尝试了:.{21}(.)\K(.*?\1)+
第一个捕获组有我想要的字符,我可以利用 \K 从最后一场比赛开始。但是,我怎样才能匹配字符串的其余部分?
期望的输出是:
This is a test string. Now comes a different one. And yet an another one to demonstrate what I want. Hello there. How can I achieve to replace all exclamation mark to point.
提前致谢!
【问题讨论】: