且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

正则表达式:匹配除反向引用之外的所有内容

更新时间:2022-11-14 19:46:23

使用组匹配.

在那里你用第一个字符创建一个组,然后把组 (1) 放在最后.

There you create a group with the 1st character, and then put group (1) at the end.

^(.).*1$

egrep '^(.).*1$'  

相反:

^(.).*((?!1).)+$

pcregrep '^(.).*((?!1).)+$'