If I understand your problem correctly it is being caused by the default list seperator
which is set to a space as default. This is used to seperate array values interpolated into a string hence your regex is also allowing spaces in the character class, which I believe is becoming
in your example above.
I tried code similar to yours with the following line added before the interpolation and it worked fine for me.
Note: all opinion in this post is from a newbie, "wow I think I understood something!" point of view :)