I need help with regex. I need to create a rule that would preserve everything between quotes and exclude quotes. For example: I want this...
STRING_ID#0="Stringtext";
...turned into just...
Stringtext
Thanks!
The way to do this is with capturing groups. However, different languages handle capturing groups a little differently. Here's an example in Javascript:
var str = 'STRING_ID#0="Stringtext"';
var myRegexp = /"([^"]*)"/g;
var arr = [];
//Iterate through results of regex search
do {
var match = myRegexp.exec(str);
if (match != null)
{
//Each call to exec returns the next match as an array where index 1
//is the captured group if it exists and index 0 is the text matched
arr.push(match[1] ? match[1] : match[0]);
}
} while (match != null);
document.write(arr.toString());
The output is
Stringtext
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With