How to use positive lookahead for a specific word in apache regex -
how use positive lookahead specific word in apache regex.
example:
in java regex have following regex ^(?=.*\blocal\sservice\b)
.
what equivalent regex in apache regex? there positive lookahead in apache regex equivalent ?=
in short: apace uses pcre regex engine, 1 of full-featured engines out there. can use same lookahead used in java.
there slight differences, shouldn't matter pattern.
for reference: token-by-token comparison of pattern in java , pcre
- assert position @ beginning of string
^
- assert regex below can matched, starting @ position (positive lookahead)
(?=.*\blocal\sservice\b)
- java 8 interprets part differently
.*
- match single character not line break character (line feed, carriage return, next line, line separator, paragraph separator)
.*
- between 0 , unlimited times, many times possible, giving needed (greedy)
*
- between 0 , unlimited times, many times possible, giving needed (greedy)
- match single character not line break character (line feed, carriage return, next line, line separator, paragraph separator)
- pcre 8.34–8.35 utf-32 interprets part differently
.*
- match single character not line break character (line feed)
.*
- between 0 , unlimited times, many times possible, giving needed (greedy)
*
- between 0 , unlimited times, many times possible, giving needed (greedy)
- match single character not line break character (line feed)
- java 8: assert position @ word boundary (position preceded or followed—but not both—by unicode letter, digit, or underscore)
\b
- pcre 8.34–8.35 utf-32: assert position @ word boundary (position preceded or followed—but not both—by ascii letter, digit, or underscore)
\b
- match character string “local” literally (case sensitive)
local
- match single character “whitespace character” (ascii space, tab, line feed, carriage return, vertical tab, form feed)
\s
- match character string “service” literally (case sensitive)
service
- java 8: assert position @ word boundary (position preceded or followed—but not both—by unicode letter, digit, or underscore)
\b
- pcre 8.34–8.35 utf-32: assert position @ word boundary (position preceded or followed—but not both—by ascii letter, digit, or underscore)
\b
- java 8 interprets part differently
Comments
Post a Comment