I'm using the following expression to find the number of occurences of ' and " in a string I don't want the count to include \' or \".
$subStr = 'asdf"asdf""a\\"sdf\'asdf\'\'a\\\'sdf';
preg_match_all('/[^\\\\]\'|[^\\\\]\"/', $subStr, $matches);
echo count($matches[0]);
I expect it to return 6 but it only returns 4. I think this is because the strings "" and '' are only count once.
This is what $matches contain:
Array
(
[0] => Array
(
[0] => f"
[1] => f"
[2] => f'
[3] => f'
)
)
Is there any way I can get the count of 6? Note that I also need to exclude the \" and \'.
