Regular Expression Matching Chinese characters: [\ u4e00-\ u9fa5] matching double-byte characters (including Chinese characters): [^ \ x00-\ xff] Exploitation: calculate the length of a String (a dual-byte length meter 2, ASCII character meter 1) String. prototype. len = function () {return
Regular Expression Matching Chinese characters: [\ u4e00-\ u9fa5]
Match double-byte characters (including Chinese characters): [^ \ x00-\ xff]
Use: calculate the length of the string (a dual-byte length meter 2, ASCII character meter 1)
String. prototype. len = function () {return this. replace ([^ \ x00-\ xff]/g, 'A'). length ;}
Regular expression for matching empty rows: \ n [\ s |] * \ r
Regular expressions matching HTML tags:/<(. *)>. * <\/\ 1> | <(. *) \/>/
Regular Expression Matching spaces at the beginning and end: (^ \ s *) | (\ s * $)
Verify jpg and GIF images: ^. {1 ,}\. (j | J) (p | P) (g | G) | (g | G) (I | I) (f | F) $
Verify the IP address:
^ (25 [0-5] | 2 [0-4] [0-9] | [0-1] {1} [0-9] {2} | [1 -9] {1} [0-9] {1} | [1-9]) \. (25 [0-5] | 2 [0-4] [0-9] | [0-1] {1} [0-9] {2} | [1- 9] {1} [0-9] {1} | [1-9] | 0) \. (25 [0-5] | 2 [0-4] [0-9] | [0-1] {1} [0-9] {2} | [1- 9] {1} [0-9] {1} | [1-9] | 0) \. (25 [0-5] | 2 [0-4] [0-9] | [0-1] {1} [0-9] {2} | [1- 9] {1} [0-9] {1} | [0-9]) $