Java regex with a positive look behind of a negative look ahead

£可爱£侵袭症+ 提交于 2019-12-05 11:33:08

The comma appears because the capturing group contains it.

You can make the outside capture group noncapturing with (?:)

(?<=(?:,(?!.*\Q(.*)\E))).*

It seems that I have solved my problem alone, removing the capturing group around the negative look ahead. It gives the following regex: (?<=,(?!.*\Q(.*)\E)).*.

It is linked with the behavior of capturing groups in look arounds as explained here: http://www.regular-expressions.info/lookaround.html in the part Lookaround Is Atomic.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!