"^ \ D + $" // non-negative integer (positive integer + 0)
"^ [0-9] * [1-9] [0-9] * $" // positive integer
"^ (-\ D +) | (0 +) $" // non-positive integer (negative integer + 0)
"^-[0-9] * [1-9] [0-9] * $" // negative integer
"^ -? \ D + $ "// integer
"^ \ D + (\. \ D + )? $ "// Non-negative floating point number (Positive floating point number + 0)
"^ ([0-9] + \. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * \. [0-9] +) | ([0-9] * [1-9] [0-9] *) $ "// Positive floating point number
"^ (-\ D + (\. \ D + )?) | (0 + (\. 0 + )?)) $ "// Non-Positive floating point number (negative floating point number + 0)
"^ (-([0-9] + \. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * \. [0-9] +) | ([0-9] * [1-9] [0-9] *) $ "// negative floating point number
"^ (-? \ D +) (\. \ D + )? $ "// Floating point number
"^ [A-Za-Z] + $" // a string consisting of 26 English letters
"^ [A-Z] + $" // a string consisting of 26 uppercase letters
"^ [A-Z] + $" // a string consisting of 26 lowercase letters
"^ [A-Za-z0-9] + $" // string consisting of digits and 26 letters
"^ \ W + $" // a string consisting of digits, 26 letters, or underscores
"^ [\ W-] + (\. [\ W-] +) * @ [\ W-] + (\. [\ W-] +) + $ "// email address
"^ [A-Za-Z] +: // (\ W + (-\ W + )*)(\. (\ W + (-\ W + )*))*(\? \ S *)? $ "// URL
"^ (D {2} | D {4})-(0 ([1-9] {1}) | (1 [1 | 2]) -([0-2] ([1-9] {1}) | (3 [0 | 1]) $ "// year-month-day
"^ (0 ([1-9] {1}) | (1 [1 | 2]) /([0-2] ([1-9] {1}) | (3 [0 | 1]) /(d {2} | D {4}) $ "// month/day/year
"^ ([W-.] +) @ ([0-9] {1, 3 }. [0-9] {1, 3 }. [0-9] {1, 3 }.) | ([w-] + .) +) ([A-Za-Z] {2, 4} | [0-9] {1, 3}) (]?) $ "// Email
"(D + -)? (D {4 }-? D {7} | D {3 }-? D {8} | ^ d {7, 8}) (-D + )? "// Phone number
"^ (D {1, 2} | 1dd | 2 [0-4] d | 25 [0-5]). (d {1, 2} | 1dd | 2 [0-4] d | 25 [0-5]). (d {1, 2} | 1dd | 2 [0-4] d | 25 [0-5]). (d {1, 2} | 1dd | 2 [0-4] d | 25 [0-5]) $ "// ip address
^ ([0-9a-f] {2}) (-[0-9a-f] {2}) {5} $ // Regular Expression of the MAC address
^ [-+]? \ D + (\. \ D + )? $ // Value Type Regular Expression
Qregexp is a regular expression class of QT.
Qt has two regular expressions of different classes.
The first class is metacharacters. It represents one or more constant expressions.
The first class is an escape character, which represents a special character.
1. metacharacters
. match any single character. for example, 1.3 may be 1. followed by any character, followed by 3
^ matches the first character of the string. for example, ^ 12 may be 123, but cannot be 312
$ matches the end of a string. for example, 12 $ can be 312. If it cannot be 123,
[] matches any character entered in brackets. [123] can be 1, 2, or 3
* matches any number of leading characters. for example, 1*2 can be any number of 1 (or even No), followed by a 2
+ matches at least one leading character. for example, 1 + 2 must be one or more 1 followed by 2
? Matches a leading character or is empty. For example, 1? 2 can be 2 or 12
2. unified mode
Use qregexp: setpatternsyntax (qregexp: wildcard) to set metacharacters to the unified mode. in the unified mode, only three metadatables can be used. their functions remain unchanged.
? Match any single character, for example, 1? 2 can be 1, followed by any single character, and 2
* match any character sequence. for example, 1*2 can be 1, followed by any number of characters, followed by 2
[] matches a defined Character Set combination. for example, [A-Za-Z \.] it can match any character and. [^ A] matches characters other than lowercase.
3. escape Sequence
\. match ". "
\ ^ match" ^ "
\$ match" $ "
\ [Match" ["
\] match"] "
\ * match" * "
\ + match" + "
\? Match "? "
\ B matches the bell character to make the computer beep.
\ t tabulation symbol
\ n line break symbol
\ r carriage return
\ s any space
\ xnn matches the hexadecimal NN character
\ 0nn matches 8-digit NN characters
these expressions start, it is the same as the Escape Character of C ++. to define an escape sequence in qregexp,
Add two \\