Menu

#13 regexps cannot be anchored to key start

open
nobody
6
2004-08-12
2004-08-12
No

(merge-rule "^a" "d" :eregexp) matches all a's.
I.e., "abca" is mapped to "dbcd".

Test case is in examples/regex-anchor.*.

Log output, on level 1:
Mappings: add (merge-rule `^^a' `d' :eregexp).
Mappings: (compare `abca' :eregexp `^^a') match!
Mappings: (compare `bca' :eregexp `^^a')
Mappings: (compare `ca' :eregexp `^^a')
Mappings: (compare `a' :eregexp `^^a') match!
Mappings: (merge-mapping `abca') -> `dbcd'.

Seems to be due to the introduction of sorting phases.
To support forward and backward sorting, Roger anchors
all regexps and runs them over successive key
suffixes/prefixes. Then, "^a" will match any a.

A similar problem with "a$" should not occur. If we
sort backwards, we're only changing the order of
comparisons, but not the comparison keys.

A rule like "^a" should only be tried at the very start
of the complete key, but not with suffixes any more.

There are more complex regexps like "(^|\)a". We must
document that we will not support them, but will ignore
the ^ in that case.

Discussion


Log in to post a comment.