From man 3 regex
:
regcomp() is supplied with preg, a pointer to a pattern buffer storage area; regex, a pointer to the null-terminated string and cflags, flags used to determine the type of compilation.
So, the Regex "\x00"
, just like "\x00whatever"
, being evaluated as a null-terminated string, is de-facto equal to ""
, the empty string.
and matching anything on the empty string, will always yield ("", "", your_original_string)
.
The best solution is to probably use Text.Regex.TDFA
, which doesn't exhibit this behavior as I mentioned in a previous comment