• Regular Expression with .Net(不包含关于Unicode的内容)


    Character Classes
    一个character class表示一组用于匹配输入字符串的字符集合。

    • [character_group]
       (Positive character group.) Matches any character in the specified character group. 例如,[1ert]将会匹配这4个字符中的任何一个
    •  [^character_group]
       (Negative character group.) Matches any character not in the specified character group.例如,[^1ert]将会匹配这4个字符中的任何一个
    •  [firstCharacter-lastCharacter]
       (Character range.) Matches any character in a range of characters. 例如,[1-9]将会匹配这9个字符中的任何一个。[0-9a-fA-F]可以批评字母和数字
    • .
       (The period character.) Matches any character except \n. This means that it also matches \r (the carriage return character, \u000D). If modified by the RegexOptions.Singleline option, a period character matches any character. 注意:a period character in a positive or negative character group [.] is treated as a literal period character, not as a character class.相当于被转义了。
    • \p{name}
       Matches any character in the Unicode general category or named block specified by name (for example, Ll, Nd, Z, IsGreek, and IsBoxDrawing).
    • \P{name}
       Matches any character not in Unicode general category or named block specified in name.
    • \w
       Matches any word character. Equivalent to the Unicode general categories [\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}\p{Lm}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \w is equivalent to [a-zA-Z_0-9].
    • \W
       Matches any nonword character. Equivalent to the Unicode general categories [^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}\p{Lm}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \W is equivalent to [^a-zA-Z_0-9].
    • \s
       Matches any white-space character. Equivalent to the escape sequences and Unicode general categories [\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \s is equivalent to [ \f\n\r\t\v].
    • \S
       Matches any non-white-space character. Equivalent to the escape sequences and Unicode general categories [^\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \S is equivalent to [^ \f\n\r\t\v].
    • \d
       Matches any decimal digit. Equivalent to \p{Nd} for Unicode and [0-9] for non-Unicode, ECMAScript behavior.
    • \D
       Matches any nondigit character. Equivalent to \P{Nd} for Unicode and [^0-9] for non-Unicode, ECMAScript behavior.

    Atomic Zero-Width Assertions

    • ^
       Specifies that the match must occur at the beginning of the string or the beginning of the line.[字符串头或者行首]
    • $
       Specifies that the match must occur at the end of the string or before \n at the end of the string. If the RegexOptions.Multiline option is set, the match can also occur at the end of a line. Note that $ matches \n but does not match \r\n (or the combination of CR and LF characters). To match the CR and LF character combination, include \r+$ in the regular expression pattern.[字符串尾]
    • \A
       Specifies that the match must occur at the beginning of the string (ignores the RegexOptions.Multiline option).
    • \Z
       Specifies that the match must occur at the end of the string or before \n at the end of the string (ignores the RegexOptions.Multiline option).
    • \z
       Specifies that the match must occur at the end of the string (ignores the RegexOptions.Multilineoption).
    • \G
       Specifies that the match must occur at the point where the previous match ended. When used with Match.NextMatch, this ensures that matches are all contiguous. 
    • \b
       Specifies that the match must occur on a boundary between \w (alphanumeric) and \W (nonalphanumeric) characters. The match must occur on word boundaries (that is, at the first or last characters in words separated by any nonalphanumeric characters). The match can also occur on a word boundary at the end of the string. 例如,\bcat\b可以匹配"The cat is crying",而\bcat可以匹配"The category is clear", cat\b可以匹配"His name is hellocat "
    • \B
       Specifies that the match must not occur on a \b boundary.
  • 相关阅读:
    如何获取地址栏中的参数
    Ajax基础知识
    什么是BFC
    111
    不定宽 块状元素居中3
    POJ 2104主席树
    可持久化数据结构之主席树
    线段树
    Splay 学习
    hello world
  • 原文地址:https://www.cnblogs.com/whyandinside/p/1558217.html
Copyright © 2020-2023  润新知