|
Regular expression that matches Chinese characters: [\u4e00-\u9fa5]
Commentary: Matching Chinese is really a headache, and it's easy with this expression
Match double-byte characters (including Chinese characters): [^\x00-\xff]
Commentary: Can be used to calculate the length of a string (a double-byte character length meter 2, ASCII character meter 1)
Regular expression matching blank lines:\n\s *\r
Commentary: Can be used to delete blank lines
Regular expression matching HTML tags: <(\S *?) [^>] *>. *? | <. *? />
Commentary: The version circulated on the Internet is too bad. The above one can only match parts. It is still powerless for complex nested tags.
Regular expression that matches leading and trailing whitespace characters: ^\s * |\s * $
Comment: Can be used to remove whitespace at the beginning and end of a line (including spaces, tabs, form feeds, etc.), very useful expressions
Regular expression matching email address:\w + ([-+.]\w +) * @\w + ([-.]\w +) *\.\w + ([-.]\w +) *
Commentary: Useful for form validation
Regular expression matching URL URL: [a-zA-z] +: // [^\s] *
Commentary: The version circulated on the Internet has limited functions. The above can basically meet the needs.
Whether the account number is valid (beginning with a letter, 5-16 bytes are allowed, and alphanumeric underscores are allowed): ^ [a-zA-Z] [a-zA-Z0-9 _] {4,15} $
Commentary: Useful for form validation
Match domestic phone number:\d {3} -\d {8} |\d {4} -\d {7}
Commentary: Matches such as 0511-4405222 or 021-87888822
Match QQ number: [1-9] [0-9] {4,}
Commentary: Tencent QQ number starts from 10000
Match Chinese postal code: [1-9]\d {5} (?!\d)
Commentary: China postcode is 6 digits
Match ID:\d {15} |\d {18}
Commentary: Chinese ID is 15 or 18
Match IP address:\d +\.\d +\.\d +\.\d +
Commentary: Useful when extracting IP addresses
Match specific numbers:
^ [1-9]\d * $ // Match a positive integer
^-[1-9]\d * $ // Match a negative integer
^-? [1-9]\d * $ // Match an integer
^ [1-9]\d * | 0 $ // Match non-negative integer (positive integer + 0)
^-[1-9]\d * | 0 $ // Match a non-positive integer (negative integer + 0)
^ [1-9]\d *\.\d * | 0\.\d * [1-9]\d * $ // Match positive floating point numbers
^-([1-9]\d *\.\d * | 0\.\d * [1-9]\d *) $ // Match negative floating point number
^-? ([1-9]\d *\.\d * | 0\.\d * [1-9]\d * | 0?\.0 + | 0) $ // match floating point number
^ [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-point numbers (negative floating-point numbers + 0)
Comment: useful when dealing with large amounts of data, pay attention to correction when specific applications
Matches a specific string:
^ [A-Za-z] + $ // Matches a string of 26 English letters
^ [A-Z] + $ // Matches a string of 26 English capitals
^ [a-z] + $ // Matches a string of 26 lowercase English letters
^ [A-Za-z0-9] + $ // Matches a string of numbers and 26 English letters
^\w + $ // Matches a string consisting of numbers, 26 English letters, or underscores
Commentary: The most basic and most commonly used expressions
Email: [_a-z0-9-] + (\. [_ A-z0-9-] +) * @ [a-z0-9-] + (\. [A-z0-9-] +) + $
Or: w + ([-+.] W +) * @ w + ([-.] W +) *. W + ([-.] W +) *
Regular expression matching Chinese characters: [u4e00-u9fa5]
Match double-byte characters (including Chinese characters): [^ x00-xff]
Regular expression matching empty lines: n [s |] * r
Regular expressions that match HTML tags: /<(.*)>.*|<(.*) /> /
Regular expression matching leading and trailing spaces: (^ s *) | (s * $)
Match IP address:\d +\.\d +\.\d +\.\d +
Regular expression matching URL: ^ [a-zA-z] +: // (w + (-w +) *) (. (W + (-w +) *)) * (? S *)? $
Whether the account is valid (beginning with a letter, 5-16 bytes are allowed, and alphanumeric underscores are allowed): ^ [a-zA-Z] [a-zA-Z0-9 _] {4,15} $
Match domestic phone number: (d {3}-| d {4}-)? (D {8} | d {7})?
Match ID:\d {15} |\d {18}
Match Tencent QQ number: ^ [1-9] * [1-9] [0-9] * $
Regular expression that matches Chinese characters: [\u4e00-\u9fa5]
Match double-byte characters (including Chinese characters): [^\x00-\xff]
Regular expression matching empty lines:\n [\s |] *\r
Regular expressions that match HTML tags: /<(.*)>.*<\/\1>|<(.*)\/> /
Regular expressions matching leading and trailing spaces: (^\s *) | (\s * $) (a trim function like vbscript)
Regular expression matching email address:\w + ([-+.]\w +) * @\w + ([-.]\w +) *\.\w + ([-.]\w +) *
Regular expression matching URL URL: http: // [[\w-] +\.) + [\w-] + (/ [\w- ./?%&=]*)? |
|