I'm trying to get a regex that will find a double quoted strings within a double quoted string. For example:
"some text "string 1" and "another string" etc"
I would like to pick out "string 1" and "another string".
I got as far as \"[^\"]*\" but this will match "some text " in the example.  I basically need to ignore the first and last quotes and match within that.  
Edit: The example mentioned doesn't have literal quotes surrounding it, but it is a Javascript string. The example regex is matching the entire string first. My Javascript is as follows.
var string = 'some "text" etc';
var pattern = new RegExp('\"[^\"]*\"/g');
var result = pattern.exec(string);
console.log("result: ", string);
// some "text" etc
So it could be my implementation of regex in Javascript that is the problem.
Don't escape the ". And just look for the text between quotes (in non greedy mode .*?) like:
var string = 'some text "string 1" and "another string" etc';
var pattern = /".*?"/g;
var current;
while(current = pattern.exec(string))
    console.log(current);
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