Debugging Tools: Regexbuddy Regular expression meta characters Total 12: $ () * +. ? [ \ ^ { | Note: The above list does not contain a closing bracket], hyphen-, right curly brace} 1.],-only to be a meta character only if it is not escaped 2.} is only a meta character if it is not escaped 3. There is no need to escape at any time from the line 4. The start and end of the character class are represented by the [and] metacharacters, respectively The forward slash in 5.Javascript/is used to define a regular expression. 6. (A|ab) and (ab|a) match the value is not the same, because (A|ab) a match will not go to execute AB's horse With The ^ metacharacters match a string or the start of a line, in the first character bit in [], representing
is a situation in which no character in square brackets can match. If [^a-f] refers to a match that is not a~f The characters within the range. The $ metacharacters match a string or the end position of a line \< and \> characters match the start and end of a word, respectively . matches any alphabetic character (either uppercase or lowercase) or a number ? indicates that the preceding character at descriptor is optional, such as https?:/ /, you can match http://and https:// * Indicates that the associated pattern appears 0 or more times, such as abc[0-9]* can match abc,abc023,
ABC2334 + indicates that the associated pattern occurs one or more times, and at least once, such as abc[0-9]* can match abc023,abc2334, but not matching ABC {n} syntax: such as abc[0-9][0-9][0-9] can be represented by abc{3}, ABC22,ABC03, etc. {N,m} represents the lowest match n times, the highest m times. such as {0,1} in the same role {N,} represents at least n times, up to infinite times. As {0,} in the * effect is the same, {1,} in + function the same The \w metacharacters only match English alphabetic characters, numbers, and underscores. It differs from the. Meta character because it does not With pictographic symbols, punctuation. Same as [a-za-z0-9] \w matches all characters except the \w match \d represents a number, \d represents a non-numeric (Office,editplus does not support) the same as [0-9] The characters that match the \d metacharacters include alphabetic characters (English and non-English letters/characters) and whitespace characters (such as Spaces The \s character matches any single whitespace character. Specifically: A spaces, a tab, and a Line feed The \s character is used to match any non-white-space character. \ t meta character matches a tab \ n metacharacters match a newline character \b, which matches the bounds of a word (appearing at the beginning and end of a word) \b, which, contrary to \b, matches the position of a non word boundary. The difference between different schools Match the time in the lyrics: [00:01.12] Little Shenyang-laughing Lake expressed in editplus or word with a regular expression: \[[0-5][0-9]:[0-5][0-9]\. [0-9] [0-9]] Note: \[represents "[" [0-5] indicates that this character bit is a number of 0 to 5, and is a [0-9] indicates that this character bit is a number of 0 to 9, and is a : Do not need to escape to indicate that itself \. Escape character representation. ] Do not need to escape, the expression itself] Expressed in a regular expression in Java or. NET: \[[0-59]\D:[0-59]\D\.\D{2}] Note: \[represents "[" [0-59]\d indicates that this character bit is a number from 0 to 59. : Do not need to escape to indicate that itself \d{2} represents a two-digit number
e-mail Regular expression: \w+@\w+\. [a-za-z]+ such as webmaster@nsjy.com
Link address regular expression in Web page: ((https? =\w+\.):/ /\w+\.. +\.\w+.* (? =\b ')) | (https?:/ /\w+\.. +\.\w+.* (? =\b ")) | (https?:/ /\w+\.. +\.\w+.* (? =\b/))) Word Regular expression metacharacters (some differences from the standard)
Regular expressions are used in JavaScript; <script> function Validinfo () { var Temp=document.getelementbyid ("Txtname"). Value; if (temp== "") {alert ("Please enter content"); var partern=/\d+/; if (!partern.exec (temp)) Alert ("Please enter a number"); Else Alert ("Hello"); } </script>
|