But we are both in agreement that there isnt a good way to do this
Agreed. Anything that tries to generalize beyond
"\Q$string\E" requires a variety of assumptions.
BTW, is the . really necessary? I dont think it is as the s/// will
just skip the char if it doesnt match.
Just trying to be careful :-) In case I neglected something with
those classes, and that something also required escaping,
then just leaving it in the string wouldn't result in a valid re.
(I don't tend to use POSIX char classes either, so I wasn't sure
exactly how inclusive I was being).