📄 escapesequences.html
字号:
<HTML><HEAD><TITLE> Regular Expressions </TITLE></HEAD><BODY><A NAME="Metacharacters"></A><H2> Metacharacters </H2><P><H3>Escaping Metacharacters</H3></P><P>In a regular expression (regex), most ordinary characters match themselves. For example, `ab%' would match anywhere `a' followed by `b' followed by `%'appeared in the text. Other characters don't match themselves, but aremetacharacters. For example, backslash is a special metacharacter which'escapes' or changes the meaning of the character following it. Thus, tomatch a literal backslash would require a regular expression to have twobackslashes in sequence. NEdit provides the following escape sequences sothat metacharacters that are used by the regex syntax can be specified asordinary characters.</P><P><PRE> \( \) \- \[ \] \< \> \{ \} \. \| \^ \$ \* \+ \? \& \\</PRE></P><P><H3>Special Control Characters</H3></P><P>There are some special characters that are difficult or impossible to type. Many of these characters can be constructed as a sort of metacharacter orsequence by preceding a literal character with a backslash. NEdit recognizesthe following special character sequences:</P><P><PRE> \a alert (bell) \b backspace \e ASCII escape character (***) \f form feed (new page) \n newline \r carriage return \t horizontal tab \v vertical tab</PRE></P><P><PRE> *** For environments that use the EBCDIC character set, when compiling NEdit set the EBCDIC_CHARSET compiler symbol to get the EBCDIC equivalent escape character.)</PRE></P><P><H3>Octal and Hex Escape Sequences</H3></P><P>Any ASCII (or EBCDIC) character, except null, can be specified by usingeither an octal escape or a hexadecimal escape, each beginning with \0 or \x(or \X), respectively. For example, \052 and \X2A both specify the `*'character. Escapes for null (\00 or \x0) are not valid and will generate anerror message. Also, any escape that exceeds \0377 or \xFF will either causean error or have any additional character(s) interpreted literally. Forexample, \0777 will be interpreted as \077 (a `?' character) followed by `7'since \0777 is greater than \0377.</P><P>An invalid digit will also end an octal or hexadecimal escape. For example,\091 will cause an error since `9' is not within an octal escape's range ofallowable digits (0-7) and truncation before the `9' yields \0 which isinvalid.</P><P><H3>Shortcut Escape Sequences</H3></P><P>NEdit defines some escape sequences that are handy shortcuts for commonlyused character classes.</P><P><PRE> \d digits 0-9 \l letters a-z, A-Z, and locale dependent letters \s whitespace \t, \r, \v, \f, and space \w word characters letters, digits, and underscore, `_'</PRE></P><P>\D, \L, \S, and \W are the same as the lowercase versions except that theresulting character class is negated. For example, \d is equivalent to`[0-9]', while \D is equivalent to `[^0-9]'.</P><P>These escape sequences can also be used within a character class. Forexample, `[\l_]' is the same as `[a-zA-Z_]', extended with possible locale dependent letters. The escape sequences for special characters, and octaland hexadecimal escapes are also valid within a class.</P><P><H3>Word Delimiter Tokens</H3></P><P>Although not strictly a character class, the following escape sequencesbehave similarly to character classes:</P><P><PRE> \y Word delimiter character \Y Not a word delimiter character</PRE></P><P>The `\y' token matches any single character that is one of the charactersthat NEdit recognizes as a word delimiter character, while the `\Y' tokenmatches any character that is NOT a word delimiter character. Word delimitercharacters are dynamic in nature, meaning that the user can change them throughpreference settings. For this reason, they must be handled differently by theregular expression engine. As a consequence of this, `\y' and `\Y' can not beused within a character class specification.<P><HR></P><P></P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -