BrantC

###### 正则表达式语法讲解（三）

Modifiers

Modifiers are for changing behaviour of TRegExpr.

There are many ways to set up modifiers.
Any of these modifiers may be embedded within the regular expression itself using the (?...) construct.
Also, You can assign to appropriate TRegExpr properties (ModifierX for example to change /x, or ModifierStr to change all modifiers together). The default values for new instances of TRegExpr object defined in global variables, for example global variable RegExprModifierX defines value of new TRegExpr instance ModifierX property.
{TODO    下面的翻译不好，恳请指教}

Do case-insensitive pattern matching (using installed in you system locale settings), see also InvertCase.

m

Treat string as multiple lines. That is, change "^'' and "$'' from matching at only the very start or end of the string to the start or end of any line anywhere within the string, see also Line separators. 处理多行文本。意味着，"^'' and "$''不仅匹配本行的开头和结尾，而是目标串中的任意开头和结尾，参见行分隔符。

s

Treat string as single line. That is, change ".'' to match any character whatsoever, even a line separators (see also Line separators), which it normally would not match.

g

Non standard modifier. Switching it Off You'll switch all following operators into non-greedy mode (by default this modifier is On). So, if modifier /g is Off then '+' works as '+?', '*' as '*?' and so on

x

Extend your pattern's legibility by permitting whitespace and comments (see explanation below).

r

Non-standard modifier. If is set then range ? additional include russian letter '?, ?? additional include '?, and ??include all russian symbols.
Sorry for foreign users, but it's set by default. If you want switch if off by default - set false to global variable RegExprModifierR.

The modifier /x itself needs a little more explanation. It tells the TRegExpr to ignore whitespace that is neither backslashed nor within a character class. You can use this to break up your regular expression into (slightly) more readable parts. The # character is also treated as a metacharacter introducing a comment, for example:

(
(abc) # comment 1
|   # You can use spaces to format r.e. - TRegExpr ignores it
(efg) # comment 2
)

This also means that if you want real whitespace or # characters in the pattern (outside a character class, where they are unaffected by /x), that you'll either have to escape them or encode them using octal or hex escapes. Taken together{TODO 不晓得怎么翻译}, these features go a long way towards making regular expressions text more readable.

Perl extensions
Perl扩展

{TODO    不知道}
(?imsxr-imsxr)
You may use it into r.e. for modifying modifiers by the fly. If this construction inlined into subexpression, then it effects only into this subexpression

Examples:
(?i)Saint-Petersburg       matchs 'Saint-petersburg' and 'Saint-Petersburg'
(?i)Saint-(?-i)Petersburg matchs 'Saint-Petersburg' but not 'Saint-petersburg'
(?i)(Saint-)?Petersburg    matchs 'Saint-petersburg' and 'saint-petersburg'

((?i)Saint-)?Petersburg    matchs 'saint-Petersburg', but not 'saint-petersburg'

(?#text)
A comment, the text is ignored. Note that TRegExpr closes the comment as soon as it sees a ")", so there is no way to put a literal ")" in the comment.

Internal mechanism explanation

It seems You need some internal secrets of TRegExpr?
Well, it's under constraction, please wait some time..
Just now don't forget to read the FAQ (expecially 'non-greediness' optimization question).

#### JS正则表达式——语法详解（二）

2016-08-02 17:50:09

#### 正则表达式的语法 正则表达式语法

2011年01月19日 19KB 下载

#### JSP 之 三大指令、四大基本语法、七大动作、九大内置对象

2017-06-18 00:05:07

#### java正则表达式语法详解及其使用代码实例

2014-06-06 09:32:55

#### 正则表达式语法.pdf

2010年02月08日 94KB 下载

#### 正则表达式语法详解正则表达式语法详解

2011年02月27日 74KB 下载

#### C++中正则表达式使用，正则表达式语法以及常用正则表达式大全

2009-11-20 22:19:00

#### 正则表达式的语法,正则表达式的语法,

2008年09月18日 36KB 下载

#### 正则表达式入门教程(XML SCHEMA应用)

2009年06月13日 55KB 下载

#### 正则表达式ppt并提供例题参考

2008年04月17日 269KB 下载