正则表达式替换文本

用正则式实现文本的替换,并保留原有字符串。

例如:

This is a small 100  test!

This is a small 234 test!

替换为:

This is a small [100] test!

This is a small [234] test!

就可以用这样的方法替换:

查找:(\d\d\d)

替换为:[$1]

$1代表匹配到的第一对括号里的内容。

No Comments

Add a Comment