例如:
specified_character = "你好啊"
str_to_replace1 = "你好啊朋友"
str_to_replace2 = "你好啊"
我想要一个正则表达式来匹配整个specified_character
. 它说只有str_to_replace2
会匹配。我目前有:
/(?<=[^\p{Han}])#{specified_character}(?=[^\p{Han}])/
结果:
str_to_replace1 = "你好啊朋友"
str_to_replace2 = "new text"