我想匹配以!
开头的骆驼套词,例如!RedHat
中包含的$line
。我正在使用php 5.3.10-1ubuntu2 with Suhosin-Patch (cli)
。
我正在尝试以下事项:
$line = preg_replace(" !([A-Z])", " $1", $line);
PHP Warning: preg_replace(): No ending delimiter '!' found
$line = preg_replace(" \!([A-Z])", " $1", $line);
PHP Warning: preg_replace(): Delimiter must not be alphanumeric or backslash
$line = preg_replace(" [!]([A-Z])", " $1", $line);
PHP Warning: preg_replace(): Unknown modifier '('
$line = preg_replace(" [\!]([A-Z])", " $1", $line);
PHP Warning: preg_replace(): Unknown modifier '('
在PHP regexp中匹配!
的正确方法是什么?