Regex issue using ICU regex to find numbers not inside parentheses

笑着哭i 提交于 2019-12-06 11:40:56

Your negative lookbehind is positioned incorrectly. Lookbehind's do not modify the input position, your negative lookbehind should come after your \d{1,4} expression:

(?i)\\d{1,4}(?<!v|vol|vol\\.|v\\.)(?![\\(]{0}.*\\))

Alternatively, just use a negative lookahead to accomplish the same purpose:

(?i)(?!v|vol|vol\\.|v\\.)\\d{1,4}(?![\\(]{0}.*\\))

Finally ended up with this regex:

(?i)\\d{1,4}(?<!v|vol|vol\\.|v\\.)(?![^\\(]*\\))

The negative look-behind needed to change. Passes all my tests. Thanks to Alex for identifying the positioning of my NLB being wrong.

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