Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
いくつかの異なるパターンを使用していますが、それぞれにこのエラーが発生します。何が問題なのですか?
診断する私の最短のものは次のとおりです。
$pattern = "<img([^>]*[^/])>"; preg_match_all($pattern, $subject, $matches);
ありがとう
正規表現の区切り文字がありません。試す:
$pattern = "#<img([^>]*[^/])>#i";
単一のスラッシュがデフォルトの区切り文字です。これが、元の正規表現のその後の文字がエラー メッセージに含まれていた理由です。従来のスラッシュを区切り記号として使用し、区切り記号ではないスラッシュをエスケープすると、次のようになります。
$pattern = "/<img([^>]*[^\\/])>/";