https://issues.dlang.org/show_bug.cgi?id=15489

Dmitry Olshansky <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #4 from Dmitry Olshansky <[email protected]> ---
Ivan Kazmenko (In reply to Ivan Kazmenko from comment #0)
> I want to test for the pattern "two consecutive characters, arbitrary
> sequence, the same two consecutive characters".  My pattern is r"(..).*\1". 
> It works with bmatch but not with match/matchAll.  A complete example
> follows.
> 
> import std.regex, std.stdio;
> void main ()
> {
>       writeln (bmatch   ("abab",  r"(..).*\1"));  // [["abab", "ab"]]
>       writeln (match    ("abab",  r"(..).*\1"));  // [["abab", "ab"]]
>       writeln (matchAll ("abab",  r"(..).*\1"));  // [["abab", "ab"]]
>       writeln (bmatch   ("xabab", r"(..).*\1"));  // [["abab", "ab"]]
>       writeln (match    ("xabab", r"(..).*\1"));  // []
>       writeln (matchAll ("xabab", r"(..).*\1"));  // []
> }
> 
> As you can see, bmatch (usage discouraged in the docs) gives me the result I
> want, but match (also discouraged) and matchAll (way to go) don't.
> 

Well this boils down to :
a) Use what works for now.
b) You might have found a case where Thompson engine simply cannot produce the
right result.

Finally I should detect these patterns and switch between simple backtracking
and thompson engine.

--

Reply via email to