Why is the following regex not working in C using regcomp

前端 未结 2 437
滥情空心
滥情空心 2021-01-29 00:30

I have the following regex to match the last pair of braces in a string,

.+(?={)(.+)(?=})

The example string is,

abc{abc=bcd}{g         


        
2条回答
  •  攒了一身酷
    2021-01-29 01:09

    Anyway, regcomp uses POSIX BRE or ERE, which doesn't support look-ahead or look-behind.

    .+{(.+)}
    

    Grab the string you want from group index 1.

    DEMO

提交回复
热议问题