跳到主要内容

1. 引言 (Introduction)

1. 引言 (Introduction)

本规范描述一种可互操作 regular expression (缩写为 "regexp") flavor, I-Regexp.

I-Regexp 不提供 capture groups, lookahead 或 backreferences 等高级 regular expression features. 它仅支持 Boolean matching capability, 即测试给定 regular expression 是否匹配给定文本片段.

I-Regexp 支持 Unicode characters (Unicode scalar values) 的完整 repertoire; I-Regexp strings 本身以及与其匹配的 strings 都是 Unicode scalar values 的序列 (在 interchange 时通常以 UTF-8 encoding form [STD63] 表示).

I-Regexp 是 XML Schema Definition (XSD) regular expressions [XSD-2] 的子集.

本文档包含将 I-Regexps 转换为可与若干知名 regular expression idioms 一起使用的指导.

I-Regexp 的开发受到 JSONPath Working Group (WG) 工作的推动. 该 WG 希望在其规范 [JSONPATH-BASE] 中支持在 JSONPath filters 中使用 regular expressions, 但无法找到可在流行 libraries 之间互操作的有用 regular expressions 规范.

1.1 术语 (Terminology)

本文档使用缩写 "regexp" 表示编程中通常称为 "regular expression" 的内容. 术语 "I-Regexp" 用作名词, 表示符合本规范要求的 character string (Unicode scalar values 的序列); 其复数形式为 "I-Regexps".

本规范使用 Unicode terminology; [UNICODE-GLOSSARY] 提供了良好的入口.

本文档中的关键词 "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY" 和 "OPTIONAL", 当且仅当它们以此处所示的全大写形式出现时, 应按 BCP 14 [RFC2119] [RFC8174] 中的描述解释.

本文档中的 grammatical rules 应解释为 ABNF, 如 [RFC5234] 和 [RFC7405] 中所述, 其中 [RFC5234] Section 2.3 的 "characters" 是 Unicode scalar values.