I'm working with a library which specifies a RegEx on an object. I need to add some characters into that RegEx. Is there a less hacky way of doing this?
I have no control over this.stripCharsRegex.
// this.stripCharsRegex = /[^0123456789.-]/gi
var regexChars = this.stripCharsRegex.toString();
regexChars = regexChars.substr(3,regex.length-7); // remove '/[^' and ']/gi'
var regex = new RegExp('[^£$€'+regexChars+']','gi'); // (e.g.)
this.stripCharsRegex = regex;
.source(), but this is a read-only property. You'd have to make a new regex object.