in reply to Re: Trying to find all items in between quotation and speech marks
in thread Trying to find all items in between quotation and speech marks

Note that the regex  m/["'](.*?)["']/g (and other, similar regexes in this thread) will match unbalanced quotes; e.g., it will match the substring  q{bar} in the string  q{foo 'bar" baz}.

Although he or she does not say so, what the OPer probably wants is something to match balanced quotes.

Replies are listed 'Best First'.
Re^3: Trying to find all items in between quotation and speech marks
by Marshall (Canon) on Jan 26, 2009 at 00:52 UTC
    Ok, there is also the idea of contractions. "don't", etc. another refinement...
    m/(["'])(.+?)\1/;
    If you tag the ["'], then using \1 looks for which ever quote character matched at the beginning. I think some \W also needed in some fashion. For a don't in the middle of a sentence. There may a special case when line beings with no character at all in front of the quote. Not sure what the requirements are when 'foo" is encountered or other non-standard english constructions.
    m/\W(["'])(.+?)\1\W/;
    Its tricky to think of all cases!