Question:
$str = "<h1>this is test msg</h1>";
$ruler = "/^<h1>(.*?)</h1>$/";
$res = preg_match($ruler,$str,$v);
var_dump($v);
Error:
Warning: preg_match(): Unknown modifier 'h' in /usr/local/var/www/test.php on line 36
NULL
Why is it wrong?The reason is because of my delimiter
in regular rules, the/do delimiter is used, while in </ h1> There are also /, so such errors will be reported
Solution:
1. Will < h1> I’d like to change it to </ h1> It’s OK
$ruler = "/^<h1>(.*?)<\/h1>$/";
2. Change the delimiter
Similar Posts:
- PHP: How to Solve Laravel rules preg_match(): No ending delimiter ‘/’ found
- [Solved] PHP Error: ErrorException: preg_match(): Compilation failed: invalid range in character class at offset …
- [Solved] configuration.module has an unknown property ‘loader’
- file_get_contents failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
- Perl : Quantifier follows nothing in regex; marked by
- The URI you submitted has disallowed characters…
- What happened to CodeIgniter disallowed key characters?
- Zabbix Warning: Too many processes on zabbix server
- python csv error: line contains null byte [How to Solve]
- [Solved] IDEA Unboxing of ‘stringRedisTemplate.hasKey(xx)’ may produce ‘NullPointerException’