PHP preg_replace仅在字符串中有's结束空格时工作


php preg_replace working only if there's ending space in string

我有这样的图案:

preg_replace_callback('#@abc'((.*?)')(.*?)@end.#is', ..

模板字符串:

$test = "@abc('test')<h1>test</h1>@end"; // not working
$test2 = "@abc('test')<h1>test</h1>@end "; // working

如果@end后面没有空格,为什么它不起作用?

正如@Rizier123指出的,这是正确的正则表达式:

preg_replace_callback('#@abc'((.*?)')(.*?)@end#is', ..