管道字符(|)不被接受为正则表达式的一部分

regular expression php doesn't accept (" | ' ) ,
here's my $pattern = '/(img|src)=("|')[^"'>]+/i';

How can I escape ("|') problem.

I think the problem comes for the quote ' inside the pattern. Your pattern is defined between single quotes so you've to escape the single quotes part of the pattern. Try this:

$pattern = '/(img|src)=("|\')[^"\'>]+/i';

You can try this:

$pattern = '/(img|src)=("\|')[^"'>]+/i';