C # commonly used in regular expressions summary (2)

-

 

  However, if the above procedures do not have a regular expression, while the direct use of split function to break down may be more simple procedure is as follows:

 

The following is quoted fragment:
  var = IP "10.100.20.168"
  IP = ip.split ( ".")
  Alert ( "the IP value is:" + (ip [0] * 255 * 255 * 255 + ip [1] * 255 * 255 + ip [2] * 255 + ip [3] * 1))

 

  Symbols explanation:

  \

  The next character is marked as a special character, or a literal character, or a backward reference, or an octal escape. For example, 'n' matches the character "n". '\ N' matches a newline. Sequence '\\' matches "\" and "\ (" the match "(."

  ^

  Matches the beginning of the string. If the object is set RegExp Multiline property, also matches ^ '\ n' position after or '\ r'.

  $

  Matches the input end of the string. If the object is set RegExp Multiline property, $ also matches the position before the '\ n' or '\ r'.

  *

  Matches the preceding subexpression zero or more times. For example, zo * matches "z" and "zoo". * Is equivalent to {0}.

  +

  Matches the preceding subexpression one or more times. For example, 'zo +' will match "zo" and "zoo", but can not match the "z". + Is equivalent to {1}.

  ?

  Matches the preceding subexpression zero or one. For example, "do (es)?" Matches "do" or "does" in the "do". ? Is equivalent to {0,1}.

  {n}

  n is a nonnegative integer. Matching the determined n times. For example, 'o {2}' does not match the "Bob" in the 'o', but can match the "food" in the two o.

  {n,}

  n is a nonnegative integer. Matching at least n times. For example, 'o {2,}' does not match the "Bob" in the 'o', but it can match all o "foooood" in. 'O {1,}' is equivalent to 'o +'. 'O {0,}' is equivalent to 'o *'.

  {n,m}

  m and n are non-negative integers, where n <= m. Match at least n times and match up to m times. For example, "o {1,3}" will match "fooooood" in the previous three o. 'O {0,1}' is equivalent to 'o?'. Please note that no spaces between the comma and the two numbers.

  ?

  When the character immediately to any other qualifier (*, +,?, {N}, {n,}, {n, m}) when the rear, non-greedy matching pattern. Non-greedy pattern matches as little as possible the search string, and the default greedy pattern matches as much of the string search. For example, the string "oooo", 'o +?' Matches a single "o", and 'o +' will match all 'o'.

  .

  Matches any single character except "\ n" is. To match include '\ n', including any character, like the use of '[. \ N]' mode.

  (pattern)

  Match the pattern and get the match. The matching can be obtained from the Matches have been used in collection SubMatches VBScript, JScript is used in the $ 0 ... $ 9 properties. To match parentheses characters, use '\ (' or '\)'.

  (?:pattern)

  But not to acquire matching pattern matching results, that this is a non-access match, not stored for later use. This use of "or" character (|) to combine the various parts of a model is useful. For example, 'industr (:? Y | ies) is a ratio of' industry | more brief expressions industries'.

  (?=pattern)

  Positive pre-investigation, matching the search string at the beginning of any match pattern string. This is a non-access match, that is, the match does not need to obtain for later use. For example, 'Windows (= 95 |? 98 | NT | 2000)' can match the "Windows 2000" in the "Windows", but can not match the "Windows 3.1" "Windows". Pre-check does not consume characters, that is, after a match occurs, the last match after the next match to start the search immediately, rather than starting from the characters that contains pre-investigation.

  (?!pattern)

  Negative pre-investigation, at the beginning of any match pattern string matching search string. This is a non-access match, that is, the match does not need to obtain for later use. For example 'Windows (95 |?! 98 | NT | 2000)' can match the "Windows 3.1" "Windows", but can not match the "Windows 2000" in the "Windows". Pre-check does not consume characters, that is, after a match occurs, after the last match started immediately next match search, rather than starting from the characters that contains pre-investigation

  x | and

  Match x or y. For example, 'z | food' can match the "z" or "food". '(Z | f) ood' the match "zood" or "food".

  [xyz]

  Set of characters. Matches any character included. For example, '[abc]' matches "plain" in the 'a'.

  [^xyz]

  Negative character sets. Matches any character not included. For example, '[^ abc]' matches "plain" the 'p'.

  [a-z]

  Range of characters. Matches any character within the specified range. For example, '[az]' match 'a' to any lowercase alphabetic characters 'z' within range.

  [^a-z]

  Negative character range. Matches any character not in any specified range. For example, '[^ az]' can not match any 'a' to an arbitrary character 'z' within range.

  \b

  Matches a word boundary, that is, it refers to the location and spaces between words. For example, 'er \ b' matches "never" in the 'er', but does not match the "verb" in the 'er'.

  \B

  Matching non-word boundary. 'Er \ B' matches "verb" in the 'er', but does not match the "never" in the 'er'.

 

Reproduced in: https: //www.cnblogs.com/baishiying/archive/2012/09/26/2703492.html

Guess you like

Origin blog.csdn.net/weixin_33982670/article/details/93440047