【发布时间】:2011-08-14 02:03:46
【问题描述】:
命名子模式中允许哪些字符,是否可以在命名子模式中转义?
(?<name>\w+)
我想使用这个例子 http://www.php.net/manual/en/function.preg-match.php#example-3946 并希望使用“hello-name”而不是“name”。
【问题讨论】:
标签: php regex escaping preg-match character
命名子模式中允许哪些字符,是否可以在命名子模式中转义?
(?<name>\w+)
我想使用这个例子 http://www.php.net/manual/en/function.preg-match.php#example-3946 并希望使用“hello-name”而不是“name”。
【问题讨论】:
标签: php regex escaping preg-match character
PCRE 仅允许子模式名称使用字母数字字符和下划线:
http://regexkit.sourceforge.net/Documentation/pcre/pcrepattern.html#SEC14
【讨论】:
[a-z]\w*是最安全的。