the pattern i gave is part of a much longer pattern, that is supposed to match long blocks of text containing many quote-delimited strings. i originally tried what you suggested, but preg_match() didn't stop at the first quote (the one on which i need to end the sub-pattern) but rather continued to the very last quote, counting all intermediate quotes as part of the (.*) sub-pattern.
so i tried using matching any character that isn't the backreference to force preg_match() to stop on the first quote found. i need to use the back reference because i need to allow both single and double quotes in all places, and i can't know which in advance.
example of a string i want to match:
and the pattern
$pattern = '/(\'|")([^\1])(\1)/s';
should match only
but doesn't match anything.
using
$pattern = '/(\'|")(.*)(\1)/s';
matches
which is not what i want