521 |
|
|
522 |
THE STANDARD MATCHING ALGORITHM |
THE STANDARD MATCHING ALGORITHM |
523 |
|
|
524 |
In the terminology of Jeffrey Friedl's book Mastering Regular Expres- |
In the terminology of Jeffrey Friedl's book "Mastering Regular Expres- |
525 |
sions, the standard algorithm is an "NFA algorithm". It conducts a |
sions", the standard algorithm is an "NFA algorithm". It conducts a |
526 |
depth-first search of the pattern tree. That is, it proceeds along a |
depth-first search of the pattern tree. That is, it proceeds along a |
527 |
single path through the tree, checking that the subject matches what is |
single path through the tree, checking that the subject matches what is |
528 |
required. When there is a mismatch, the algorithm tries any alterna- |
required. When there is a mismatch, the algorithm tries any alterna- |
4527 |
not always produce exactly the same result as matching over one single |
not always produce exactly the same result as matching over one single |
4528 |
long string. The difference arises when there are multiple matching |
long string. The difference arises when there are multiple matching |
4529 |
possibilities, because a partial match result is given only when there |
possibilities, because a partial match result is given only when there |
4530 |
are no completed matches in a call to fBpcre_dfa_exec(). This means |
are no completed matches in a call to pcre_dfa_exec(). This means that |
4531 |
that as soon as the shortest match has been found, continuation to a |
as soon as the shortest match has been found, continuation to a new |
4532 |
new subject segment is no longer possible. Consider this pcretest |
subject segment is no longer possible. Consider this pcretest example: |
|
example: |
|
4533 |
|
|
4534 |
re> /dog(sbody)?/ |
re> /dog(sbody)?/ |
4535 |
data> do\P\D |
data> do\P\D |