正则表达式语法

问题描述 投票:21回答:3

正则表达式是否有任何BNF语法?

regex grammar bnf
3个回答
20
投票

你可以看到一个qazxsw poi(显示qazxsw poi,由qazxsw poi发布)


8
投票

要在现场发布:

CMPT 384讲义Robert F. Cameron 1999年11月29日至12月1日

Perl regexp

通过a little more in detail here

--- Knud van Eeden --- 2003年10月21日 - 03:22 AM --------------------

PERL:搜索/替换:正则表达式:Backus Naur形式:正则表达式的BNF可能是什么?

edg

通过BNF Grammar of Regular Expressions Following the precedence rules given previously, a BNF grammar for Perl-style regular expressions can be constructed as follows. <RE> ::= <union> | <simple-RE> <union> ::= <RE> "|" <simple-RE> <simple-RE> ::= <concatenation> | <basic-RE> <concatenation> ::= <simple-RE> <basic-RE> <basic-RE> ::= <star> | <plus> | <elementary-RE> <star> ::= <elementary-RE> "*" <plus> ::= <elementary-RE> "+" <elementary-RE> ::= <group> | <any> | <eos> | <char> | <set> <group> ::= "(" <RE> ")" <any> ::= "." <eos> ::= "$" <char> ::= any non metacharacter | "\" metacharacter <set> ::= <positive-set> | <negative-set> <positive-set> ::= "[" <set-items> "]" <negative-set> ::= "[^" <set-items> "]" <set-items> ::= <set-item> | <set-item> <set-items> <set-items> ::= <range> | <char> <range> ::= <char> "-" <char>


5
投票
© www.soinside.com 2019 - 2024. All rights reserved.