Well, that might do it.
I have never actually used the S&R tool, because it makes more sense to use the Editor (or another Editor, before calibre had one). But for all I know it uses the builtin python stdlib re() instead of Matthew Barnett's enhanced regex module.
Anyway, I cannot guarantee how something might work if I don't use it and don't know that that is what the other guy is using.
...
Feel free to post your regex function to the relevant sticky in this subforum, if you feel other people might find it useful and want to make it more likely they will find it.