Regex match single and double quotes problem


I want to modify my code so that it would match both single and double quotes.

I changed this:

preg_match("/<meta[^>]+name=\\"description\\"[^>]+content=\\"([^\\"]*)\\"[^>]*>/si", $html, $match);


preg_match("/<meta[^>]+name=(?:\\"|')description(?:\\"|')[^>]+content=(?:\\"|')([^\\"]*)(?:\\"|')[^>]*>/si", $html, $match);

but it appears that the second code will crash the php without any error / warning.

What am I doing wrong?

Many thanks for help

Try using


before your function call to see what the problem is. Also, what is that you are trying to accomplish exactly with the replacement? There should be an easier way.