You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often have to generate regexes dynamically. For this the tree syntax of CL-PPCRE is the most optimal solution. However I have discovered a strange corner case. In the documentation it says that
The symbol :VOID is equivalent to the empty string.
However in practice the empty string "" and :VOID have different behavior in some cases.
Consider two parse trees: (:sequence "" "a") and (:sequence :void "a"). Logically both are supposed to match "a". However
(ppcre:create-scanner '(:sequence "" "a"))
results in an error:
Invalid index 0 for (SIMPLE-ARRAY CHARACTER (0)), should be a non-negative integer below 0.
[Condition of type SB-INT:INVALID-ARRAY-INDEX-ERROR]
The version with :void works just fine. Also if the empty string is not the first item of a sequence, it also works.
However if :sequence is replaced by :alternation, empty string causes an error in any position!
This behavior makes it harder to create dynamic regex trees, since I need to check if a string is empty and replace it with :void to avoid the error.
The text was updated successfully, but these errors were encountered:
I often have to generate regexes dynamically. For this the tree syntax of CL-PPCRE is the most optimal solution. However I have discovered a strange corner case. In the documentation it says that
However in practice the empty string
""
and:VOID
have different behavior in some cases.Consider two parse trees:
(:sequence "" "a")
and(:sequence :void "a")
. Logically both are supposed to match "a". Howeverresults in an error:
The version with
:void
works just fine. Also if the empty string is not the first item of a sequence, it also works.However if
:sequence
is replaced by:alternation
, empty string causes an error in any position!This behavior makes it harder to create dynamic regex trees, since I need to check if a string is empty and replace it with
:void
to avoid the error.The text was updated successfully, but these errors were encountered: