: A single character range: [character set] Non-range: [^character collection]/r: Enter/n: change/t: tab key/d: [0-9]/d: [^0-9]/w : [0-9a-Za-Z _]/W: [^0-9a-Za-Z _]/s: [/f/n/r/t/v]/s: [^/f/n/r/ T/V]+: One or more*: 0 or more? : 0 or one {n}: match n {min, max}: matching range {0,1}:? {0,}:*{1,}:+? : The difference between inertia matching and greedy matching/B: After that, the character is located at the first place of the string, and the previous characters are located at the end of the string tail: space, paragraph first line, paragraph end, comma, period,-/b: match non-border character character Tips: Use the file name as much as possible-instead of using _.^: The first text of the text $: All text rear (): The matching result is deemed as a whole |: or/: quotes backwards. <Name>, /k<Name>. $n: Replace the grammar, starting from 1? :: Non -acquired matching? =: Positive pre -survey
Intersection <=: Reverse Preparatory Examination
excerpt:
Matching regular expression of Chinese characters: [/U4E00-/U9FA5]
Comment: It is really a headache to match Chinese. With this expression, it is easy to handle
Matching dual-byte characters (including Chinese characters): [^/x00-/xff]
Comment: It can be used to calculate the length of the string (a dual -byte character length meter 2, ASCII characters 1)
Matching the regular expression of the blank line:/n/s*/r
Comment: Can be used to delete blank lines
Matching regular expression of HTML marked: <(/s*?) [^>]*>.*? </1> | <.*?/>
Comment: The version circulating on the Internet is too bad. The above can only match the part. It is still powerless for complex nested marks.
Matching the regular expression of the front and tail blank characters:^/s*|/s*$
Comment: It can be used to delete the blank characters (including spaces, watchmaking, page changes, etc.) at the end of the line, which can be used.
Matching the regular expression of the email address:/w+([-+.]/W+)*@/w+([-.]/W+)*/./W+([-.]/W+)*
Comment: Form verification is very practical
The regular expression of the matching URL: [a-za-z]+: // [^/s]*
Comment: The version of the version circulated on the Internet is very limited. The above can basically meet the needs
Whether the account is legal (the letter is from the beginning, allows 5-16 bytes, and the letters are allowed to draw lines):^[a-za-z] [a-za-z0-9 _] {4,15} $
Comment: Form verification is very practical
Matching domestic phone numbers:/d {3}-/d {8} |/d {4}-/d {7}
Comment: matching forms such as 0511-4405222 or 021-87888822
Matching Tencent QQ number: [1-9] [0-9] {4,}
Comment: Tencent QQ number starts from 10000
Matching China Post Coding: [1-9]/D {5} (?!/D)
Comment: 6 digits of China Post Code
Matching ID card:/d {15} |/d {18}
Comment: China's ID card is 15 or 18 -bit
Matching IP address:/d+/./D+/d+/./D+
Comment: useful when extracting IP addresses
Match a specific number:
^[1-9]/d*$ // match the positive integer
^-[1-9]/d*$ // match the negative integer
^-? [1-9]/d*$ // matching integer
^[1-9]/d*| 0 $ // match non-negative integer (positive integer+ 0)
^-[1-9]/d*| 0 $ // Match non-positive integer (negative integer+ 0)
^[1-9]/d*/./D*| 0 /./ d*[1-9]/d*$ // match the number of positive floating points
^-([1-9]/d*/./D*| 0 /./ d*[1-9]/d*) $ // match the negative floating point number
^-? ([1-9]/d*/./D*| 0 /./ d*[1-9]/d*| 0?/. 0+| 0) $ // match the number of floating points
^[1-9]/d*/./D*| 0 /./ d*[1-9]/d*| 0?/. 0+| 0 $ // Match non-negative floating point number (positive floating point number + 0)
^(-([1-9]/d*/./D*| 0 /./ d*[1-9]/d*) | 0?/. 0+| 0 $ // match non-positive floating Number (negative floating point number+ 0)
Comment: It is useful when processing a large amount of data. Pay attention to correction when applying for specific applications
Matching specific string:
^[A-Za-Z]+$ // matching string consisting of 26 English letters
^[AZ]+$ // The string composed of 26 English letters
^[AZ]+$ // The string composed of a lowercase composed of 26 English letters
^[A-Za-Z0-9]+$ // String consisting of numbers and 26 English letters
^/w+$ // match string consisting of numbers, 26 English letters or lowering lines