irregex
irregex copied to clipboard
Unexpected result for sre->string
This does not seem to be correct:
3> (sre->string '(* (/ "AZ09")))
"[]*"
I would have expected something like "[A-Z0-9]*"
.
It looks like there's some confusion over what a cset is, exactly. It's a vector, but cset->string
expects a list. And doesn't crash or complain, just ignores anything non-pair assuming it's the end of the list.
It can be fixed fairly easily by calling vector->list
on the ls
argument, but I'm not sure that's the best way. Converting to a cset and back drops the original input, so you get something like (sre->string '(~ ("XYZ"))) => "[\x00-W\\[-�\x00-�]"
when printing it. I think it'd be nicer to keep closer to the original input (so the output would be "[^XYZ]"
), so maybe we should skip the cset conversion here and roll a different implementation just for converting to strings?
Yes, that code is not well tested because I never used it :sweat_smile:
It already has handling to print complemented sets prettily but that code is also wrong.