Looking at the documents of a RegExp object and could not find a method that does what I want, or I just don't look complicated enough.
Say I have the text:
var text = "§193:And Some Text§";
And the RegExp object:
var reg = /§([0-9]+):(.*?)§/;
Running reg.match(text); will obviously give me such an array:
["§193:And Some Text§","193","And Some Text"]
Is there any way to cancel this process? Thus, I give an array with the same number of matching groups as RegExp for the function and return me the text, which will look like this:
var reg = /§([0-9]+)§(.*?)§/; var data = ["293","Some New Text"]; var text = reg.rmatch(data);
and text will now be §293:Some New Text§
I'm trying to create a plugin system for my code, and part of it entails getting a regular expression from the plugin and using it in several processes, for example. data extraction, restoration of the source text from some data.
Right now I need to make a plugin so that the function that returns the source text is hoping there is a way to do this, so they didn't just need to reuse regexp. I could prototype the user-defined function into the RegExp class and then use it, I just hoped that it already had some kind of process for this.
source share