When I'm trying to mask 9786129999999 ISBN
it results in string with doubled separator:
It doesn't look correct to me. I think the culprit here is that in this part of code
|
[group, ib[cur + 1:cur + idx + 1], ib[cur + idx + 1:-1], check]) |
the second entry in the list is
ib[6:6] (since idx is 0) and it returns an empty string.