Understanding negative lookahead

前端 未结 4 679
粉色の甜心
粉色の甜心 2020-12-05 23:01

I\'m trying to understand how negative lookaheads work on simple examples. For instance, consider the following regex:



        
4条回答
  •  执笔经年
    2020-12-05 23:27

    @Antario, I was confused about the negative look ahead/behind case in regex for a while and this site has a great explanation.

    So with your example what you are saying is that you have a literal "a" and it is NOT followed by a literal "b" and it IS followed by a literal "c".

    Here is a different regex debugger than you used which gives a more visual answer which personally I find helpful :)

    a(?!b)c

    Regular expression visualization

    Debuggex Demo

提交回复
热议问题