Page tree
Skip to end of metadata
Go to start of metadata

关键词:Regular Expression, RegExp, 正则表达式

工具

http://www.myregexp.com

https://regex101.com/

实例

匹配Id,但orderId和productId不算,必须包含其他的Id(包含orderId或productId也可以,但不能只有orderId或productId)

 

参考:http://stackoverflow.com/questions/1395177/regex-to-exclude-a-specific-string-constant

另一种解决方案

使用(?<!X),negative lookbehind

https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

http://www.rexegg.com/regex-lookarounds.html

 

另一个例子:

参考:https://stackoverflow.com/questions/406230/regular-expression-to-match-a-line-that-doesnt-contain-a-word

 

  • No labels