Regex: Match everything except backreference

后端 未结 3 2066
南旧
南旧 2021-01-14 12:49

I have the following example lines:

a_a
b_c

How (using grep/egrep) would I match the lines where the first letter

3条回答
  •  [愿得一人]
    2021-01-14 12:58

    Use a negative look behind anchored to end of input. A general regex for "first char is not last char" is:

    ^(.).*(?

    To match only your type of input:

    ^(.)_.(?

提交回复
热议问题