preg_match_all() [function.preg-match-all]: Unknown modifier ']'

后端 未结 2 1207
渐次进展
渐次进展 2020-12-10 07:10

Using a few different patterns but they each come up with this error - so what\'s wrong?

My shortest one to diagnose is:

$pattern = \"]         


        
相关标签:
2条回答
  • 2020-12-10 07:39

    A single slash is the default delimiter, which is why the character after it in your original regex was in the error-message. Using the traditional slashes as delimiters and escaping the slash that is not a delimiter would look like this:

    $pattern = "/<img([^>]*[^\\/])>/";
    
    0 讨论(0)
  • 2020-12-10 07:41

    You are lacking the regexp delimiters. Try:

    $pattern = "#<img([^>]*[^/])>#i";
    
    0 讨论(0)
提交回复
热议问题