1. Regular expressions are often used in websites. Here are some explanations and examples for your reference and modification: 2. "^ d+$"//Non negative integer (positive integer+0) 3. "^ [0-9] * [1-9] [0-9] * $"//Positive integer 4. "^ ((- d+) | (0+)) $"//Non positive integer (negative integer+0) 5. "^ - [0-9] * [1-9] [0-9] * $"//Negative integer 6. "^ -? D+$"//Integer 7. "^ d+(. d+)? $"//Non negative floating point number (positive floating point number+0) 8. "^ (([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 9. "^ ((- d+(. d+)?) | (0+(. 0+)?)) $"//Non positive floating point number (negative floating point number+0) 10. "^ (- (([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 11. "^ (-? D+) (. d+)? $"//floating point number 12. "^ [A-Za-z]+$"//A string consisting of 26 English letters 13. "^ [A-Z]+$"//A string composed of 26 uppercase English letters 14. "^ [a-z]+$"//A string composed of 26 lowercase English letters 15. "^ [A-Za-z0-9]+$"//A string consisting of numbers and 26 English letters 16. "^ w+$"//A string consisting of numbers, 26 English letters or underscores 17. "^ [w -]+(. [w -]+) * @ [w -]+(. [w -]+)+$"//email address 18. "^[a-zA-z]+://(w+(-w+)*)(.(w+(-w+)*))*(?S*)?$" //url 19./^ (d {2} | d {4}) - ((0 ([1-9] {1})) | (1 [1 | 2])) - ([0-2] ([1-9] {1})) | (3 [0 | 1]) $//Year Month Day 20./^ ((0 ([1-9] {1})) | (1 [1 | 2]))/([0-2] ([1-9] {1})) | (3 [0 | 1])/(d {2} | d {4}) $//Month/Day/Year 21. "^([w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$" //Emil 22. /^((+?[0-9]{2,4}-[0-9]{3,4}-)|([0-9]{3,4}-))?([0-9]{7,8})(-[0-9]+)?$///Phone number 23. "^ (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 24. 25. Regular expression matching Chinese characters: [u4e00-u9fa5] 26. Matching double byte characters (including Chinese characters): [^ x00 xff] 27. Regular expression matching empty lines: n [s |] * r 28. Regular expressions matching HTML tags:/<(. *)>. *</1>|<(. *)/>/ 29. Regular expressions matching first and last spaces: (^ s *) | (s * $) 30. Regular expression matching email address: w+([-+.] w+) * @ w+([-.] w+) *. w+([-.] w+)* 31. Regular expression matching URL: ^ [a-zA-z]+://( w+(- w+) *) (. ( w+(- w+) *) * (? S *)$ 32. Whether the matching account number is legal (letters start, 5-16 bytes are allowed, alphanumeric underscores are allowed): ^ [a-zA-Z] [a-zA-Z0-9_] {4,15}$ 33. Matching domestic telephone number: (d{3}-|d{4}-)?(d{8}|d{7})? 34. Match Tencent QQ number: ^ [1-9] * [1-9] [0-9]*$ 35. 36. 37. Metacharacters and their behavior in the context of regular expressions: 38. 39. Mark the next character as a special character, or a literal character, or a backward reference, or an octal escape character. 40. 41. ^ matches the start of the input string.If the Multiline property of the RegExp object is set, ^ also matches the position after 'n' or 'r'. 42. 43. $matches the end of the input string.If the Multiline attribute of the RegExp object is set, $also matches the position before 'n' or 'r'. 44. 45. * Matches the preceding subexpression zero or more times. 46. 47.+matches the preceding subexpression one or more times+Equivalent to {1,}. 48. 49. ? Matches the previous subexpression zero or once.?Equivalent to {0,1}. 50. 51. {n} n is a non negative integer, matching the determined n times. 52. 53. {n,} n is a non negative integer, matching at least n times. 54. 55. {n, m} m and n are non negative integers, where n<=m.The minimum number of matches is n and the maximum number of matches is m.There can be no space between a comma and two numbers. 56. 57. ? When this character is immediately followed by any other qualifier (*,+,?, {n}, {n,}, {n, m}), the matching pattern is non greedy.The non greedy pattern matches as few strings as possible, while the default greedy pattern matches as many strings as possible. 58. 59. . Matches any single character except "n".To match any character including 'n', use a pattern like '[. n]'. 60. (pattern) Match pattern and obtain this match. 61. 62. (?: pattern) Matches the pattern but does not obtain the matching result, that is, it is a non acquisition match and will not be stored for future use. 63. 64. (?=pattern) Forward pre query, which matches the search string at the beginning of any string matching pattern.This is a non acquisition match, that is, the match does not need to be acquired for future use. 65. 66. (?! pattern) negative preview, which is opposite to (?=pattern) 67. 68. x | y matches x or y. 69. 70. [xyz] character set. 71. 72. [^ xyz] Negative character set. 73. 74. [a-z] Character range, matching any character within the specified range. 75. 76. [^ a-z] Negative character range, matching any character not within the specified range. 77. 78. b Match a word boundary, that is, the position between the word and the space. 79. 80. B Matches non word boundaries. 81. 82. cx matches the control character indicated by x. 83. 84. d Matches a numeric character.Equivalent to [0-9]. 85. 86. D matches a non numeric character.Equivalent to [^ 0-9]. 87. 88. f Matches a new page character.Equivalent to x0c and cL. 89. 90. n matches a newline character.Equivalent to x0a and cJ. 91. 92. r matches a carriage return.Equivalent to x0d and cM. 93. 94. s Matches any white space characters, including spaces, tabs, page feeds, and so on.Equivalent to [fnrtv]. 95. 96. S matches any non whitespace character.Equivalent to [^ fnrtv]. 97. 98. t Matches a tab.Equivalent to x09 and cI. 99. 100. v matches a vertical tab.Equivalent to x0b and cK. 101. 102. w Matches any word character including underscores.Equivalent to '[A-Za-z0-9_]'. 103. 104. W Matches any non word character.Equivalent to '[^ A-Za-z0-9_]'. 105. 106. xn matches n, where n is the hexadecimal escape value.The hexadecimal escape value must be two digits long. 107. 108. num matches num, where num is a positive integer.Reference to the matched obtained. 109. 110. n identifies an octal escape value or a backward reference.If n is preceded by at least n obtained sub expressions, n is a backward reference.Otherwise, if n is an octal digit (0-7), then n is an octal escape value. 111. 112. nm identifies an octal escape value or a backward reference.If there are at least sub expressions obtained before nm, nm is a backward reference.If there are at least n acquisitions before nm, then n is a backward reference followed by the text m.If the previous conditions are not met, if n and m are octal digits (0-7), nm will match the octal escape value nm. 113. 114. nml If n is an octal digit (0-3), and m and l are both octal digits (0-7), the octal escape value nml is matched. 115. 116. un matches n, where n is a Unicode character represented by four hexadecimal digits. 117. 118. Regular expressions matching Chinese characters: [u4e00-u9fa5] 119. 120. Matching double byte characters (including Chinese characters): [^ x00 xff] 121. 122. Regular expression matching empty lines: n [s |] * r 123. 124. Regular expressions matching HTML tags:/<(. *)>. *</1>|<(. *)/>/ 125. 126. Regular expressions matching first and last spaces: (^ s *) | (s * $) 127. 128. Regular expression matching email address: w+([-+.] w+) * @ w+([-.] w+) *. w+([-.] w+)* 129. 130. Regular expressions matching URL: //([w -]+.)+[w -]+(/[w -./?%&=] *)? 131. 132. Use regular expressions to limit the input content of the text box in the web form: 133. 134. Use regular expressions to restrict input to Chinese only: onkeyup="value=value. replace (/[^ u4E00-u9FA5]/g, '')" onforecast="clipboardData. setData ('text ', clipboardData. getData ('text'). replace (/[^ u4E00-u9FA5]/g, '')" 135. 136. Use regular expressions to restrict the input of only full width characters: onkeyup="value=value. replace (/[^ uFF00 uFFFF]/g, '')" onforecast="clipboardData. setData ('text ', clipboardData. getData ('text'). replace (/[^ uFF00 uFFFF]/g, '')" 137. 138. Use regular expressions to limit the number you can only enter: onkeyup="value=value. replace (/[^ d]/g, '')" onforecast="clipboardData. setData ('text ', clipboardData. getData ('text'). replace (/[^ d]/g, '')" 139. 140. Use regular expressions to restrict the input of numbers and English only: onkeyup="value=value. replace (/[W]/g, '')" onbeforecast="clipboardData. setData ('text ', clipboardData. getData ('text'). replace (/[^ d]/g, '')" 141. 142.==========Common Regular Formula 143. 144. 145. 146. Regular expressions matching Chinese characters: [u4e00-u9fa5] 147. 148. Matching double byte characters (including Chinese characters): [^ x00 xff] 149. 150. Regular expression matching empty lines: n [s |] * r 151. 152. Regular expressions matching HTML tags:/<(. *)>. *</1>|<(. *)/>/ 153. 154. Regular expressions matching first and last spaces: (^ s *) | (s * $) 155. 156. Regular expression matching IP address:/(d+)(d+).(d+).(d+)/g // 157. 158. Regular expression matching email address: w+([-+.] w+) * @ w+([-.] w+) *. w+([-.] w+)* 159. 160. Regular expressions matching URL: //(/[w -]+.)+[w -]+(/[w -./?%&=] *)? 161. 162. SQL statement: ^ (select | drop | delete | create | update | insert)*$ 163. 164. 1. Non negative integer: ^ d+$ 165. 166. 2. Positive integer: ^ [0-9] * [1-9] [0-9]*$ 167. 168. 3. Non positive integer: ^ ((- d+) | (0+))$ 169. 170. 4. Negative integer: ^ - [0-9] * [1-9] [0-9]*$ 171. 172. 5. Integer: ^ -?d+$ 173. 174. 6. Non negative floating point number: ^ d+(. d+)$ 175. 176. 7. Positive floating point number: ^ ((0-9)+[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*.[0-9]+)|([0-9]*[1-9][0-9]*))$ 177. 178. 8. Non positive floating point number: ^ ((- d+. d+)?)|(0+(.0+)?))$ 179. 180. 9. Negative floating point number: ^ (- (positive floating point number regular expression))$ 181. 182. 10. English string: ^ [A-Za-z]+$ 183. 184. 11. English capital string: ^ [A-Z]+$ 185. 186. 12. English lowercase string: ^ [a-z]+$ 187. 188. 13. English character number string: ^ [A-Za-z0-9]+$ 189. 190. 14. English number plus underscore string: ^ w+$ 191. 192. 15. E-mail address: ^ [w -]+(. [w -]+) * @ [w -]+(. [w -]+)+$ 193. 194. 16、URL:^[a-zA-Z]+://(w+(-w+)*)(.(w+(-w+)*))*(?s*)?$ 195. Or: ^ //[A-Za-z0-9]+[A-Za-z0-9]+[/=?%-&_~`@[]':+!]*([^<>""])*$ 196. 197. 17. Postal code: ^ [1-9] d {5}$ 198. 199. 18. Chinese: ^ [u0391-uFFE5]+$ 200. 201. 19. Telephone No.: ^ (((d {2,3})) | (d{3}-))?((0d{2,3})|0d{2,3}-)?[1-9]d{6,7}(-d{1,4})?$ 202. 203. 20. Mobile phone number: ^ (((d {2,3})) | (d{3}-))?13d{9}$ 204. 205. 21. Double byte characters (including Chinese characters): ^ x00 xff 206. 207. 22. Matching first and last spaces: (^ s *) | (s * $) (trim functions like vbscript) 208. 209. 23. Matching HTML tags:<(. *)>. *</1>|<(. *)/> 210. 211. 24. Matching blank lines: n [s |] * r 212. 213. 25. Extract the network link in the information: (h | H) (r | R) (e | E) (f | F) *=* ('| ")? (w | |/|.)+(' |" | * |>)? 214. 215. 26. Email address in extracted information: w+([-+.] w+) * @ w+([-.] w+) *. w+([-.] w+)* 216. 217.27. Extract the picture link in the information: (s | S) (r | R) (c | C) *=* ('| ")? (w | |/|.)+(' |" | * |>)? 218. 219.28. IP address in extracted information: (d+)(d+).(d+).(d+) 220. 221. 29. Chinese mobile phone number in the extracted information: (86) * 0 * 13d {9} 222. 223.30. Retrieve the Chinese fixed telephone number in the information: ((d {3,4}) | d{3,4}-|s)?d{8} 224. 225. 31. Retrieve the Chinese telephone number (including mobile and fixed telephones) in the information: ((d {3,4}) | d{3,4}-|s)?d{7,14} 226. 227.32. Postal code of China in the extracted information: [1-9] {1} (d+) {5} 228. 229.33. Floating point number (i.e. decimal) in extracted information: (-? D *)?d+ 230. 231. 34. Extract any number in the information: (-? D *) (. d+)? 232. 233. 35、IP:(d+).(d+).(d+).(d+) 234. 235. 36. Telephone area code:/^ 0d {2,3}$/ 236. 237.37 Tencent QQ No.: ^ [1-9] * [1-9] [0-9]*$ 238. 239. 38. Account number (beginning with a letter, 5-16 bytes are allowed, alphanumeric underscores are allowed): ^ [a-zA-Z] [a-zA-Z0-9_] {4,15}$ 240. 241. 39. Chinese, English, numbers and underscores: ^ [u4e00-u9fa5_a-zA-Z0-9]+$