如何在apache regex中对特定单词使用正向先行。
示例:
在java正则表达式中,我有以下正则表达式^(?=.*\bLOCAL\sSERVICE\b)。
apache regex中等效的regex是什么?apache regex中是否有任何与?=等效的正向先行检查?
发布于 2014-06-03 12:50:20
简而言之:使用PCRE regex引擎,这是目前功能最齐全的引擎之一。您可以使用在Java.中使用的相同的先行
有一些细微的差异,但它们对您的模式不应该有什么影响。
参考:Java和PCRE中模式的逐个令牌比较
(?=.*\bLOCAL\sSERVICE\b) .* .* *
- PCRE 8.34–8.35 UTF-32 interprets this part differently `.*`
- Match any single character that is NOT a line break character (line feed) `.*`
- Between zero and unlimited times, as many times as possible, giving back as needed (greedy) `*`
- Java 8: Assert position at a word boundary (position preceded or followed—but not both—by a Unicode letter, digit, or underscore) `\b`
- PCRE 8.34–8.35 UTF-32: Assert position at a word boundary (position preceded or followed—but not both—by an ASCII letter, digit, or underscore) `\b`
- Match the character string “LOCAL” literally (case sensitive) `LOCAL`
- Match a single character that is a “whitespace character” (ASCII space, tab, line feed, carriage return, vertical tab, form feed) `\s`
- Match the character string “SERVICE” literally (case sensitive) `SERVICE`
- Java 8: Assert position at a word boundary (position preceded or followed—but not both—by a Unicode letter, digit, or underscore) `\b`
- PCRE 8.34–8.35 UTF-32: Assert position at a word boundary (position preceded or followed—but not both—by an ASCII letter, digit, or underscore) `\b`
https://stackoverflow.com/questions/24007309
复制相似问题