Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP中后跟特殊字符的正则表达式_Php_Regex - Fatal编程技术网

PHP中后跟特殊字符的正则表达式

PHP中后跟特殊字符的正则表达式,php,regex,Php,Regex,我想要以下单词模式的正则表达式。该模式以大括号dollar{$开头,后跟任何特殊字符,以大括号closing}结尾 我厌倦了下面的$regex='/^\\\{\$[^a-zA-Z].\\\}/I' 但是没有运气 请在这方面帮助我。不确定您想要实现什么,但问题是您的正则表达式中有一个不平衡的括号 $regex = '/(^\\{\\$[^a-zA-Z])).*?(\\})/i'; ^ remove this one 根据您的问题描述,我建

我想要以下单词模式的正则表达式。该模式以大括号dollar{$开头,后跟任何特殊字符,以大括号closing}结尾

我厌倦了下面的$regex='/^\\\{\$[^a-zA-Z].\\\}/I'

但是没有运气


请在这方面帮助我。

不确定您想要实现什么,但问题是您的正则表达式中有一个不平衡的括号

$regex = '/(^\\{\\$[^a-zA-Z])).*?(\\})/i';
                             ^ remove this one
根据您的问题描述,我建议您使用:

$regex = '/(^\\{\\$.*?\\})/i';

此处不需要双重转义,您可以对正则表达式使用\W非单词字符:

$regex = '/^\{\$\W*\}/';

谢谢它帮助了我!
$regex = '/^\{\$\W*\}/';