[pcre-dev] [Bug 1680] Creating the intersection of two regul…

Páxina inicial
Borrar esta mensaxe
Autor: admin
Data:  
Para: pcre-dev
Asunto: [pcre-dev] [Bug 1680] Creating the intersection of two regular expressions
https://bugs.exim.org/show_bug.cgi?id=1680

--- Comment #1 from Philip Hazel <ph10@???> ---
I don't think ^a\d+b$ is the intersection of ^a\d+ and \d+b$ if you mean
"matches strings that match each separate pattern". I think the intersection is
^a\d+(.+\d+)?b$ because the first means "starts with a\d+" and the second means
"ends with \d+b". The string "a123xyz456b" meets that description but does not
match ^a\d+b$.

PCRE isn't into manipulating regular expressions. However, you can write
patterns that do "and" type matching using lookahead assertions. For example,
if you want to match strings that match A and B and C (where A, B, C are
complex patterns) you can use ^(?=.*A)(?=.*B)(?=.*C) or just
^(?=.*A)(?=.*B).*C. For example, to match lines that contain both "cat" and
"dog" you can write ^(?=.*cat)(?=.*dog). [If you want to capture matched
strings, it gets a bit more involved.]

--
You are receiving this mail because:
You are on the CC list for the bug.