Create regular expressions commonly used in PHP for dynamic web pages. Regular expression for matching Chinese characters: [u4e00-u9fa5] matching double byte characters (including Chinese characters): [^ x00-xff] application: calculate the length of a string (a double byte character length meter 2, regular Expression Matching Chinese characters: [u4e00-u9fa5]
Match double byte characters (including Chinese characters): [^ x00-xff]
Application: calculate the length of a string (two-byte length meter 2, ASCII character meter 1)
Regular expression for matching empty rows: [s |] *
Regular expressions matching HTML tags:/<(. *)>. * | <(. *)/>/
Regular Expression Matching spaces at the beginning and end: (^ s *) | (s * $)
Application: javascript does not have trim functions like vbscript. we can use this expression to implement it, as shown below:
Use regular expressions to break down and convert IP addresses:
The following is a javascript program that uses regular expressions to match IP addresses and convert IP addresses to corresponding values:
However, if the above program does not use regular expressions, it may be easier to directly use the split function to separate them. The program is as follows:
Regular Expression Matching the Email address: w + ([-+.] w +) * @ w + ([-.] w + )*. w + ([-.] w + )*
The regular expression matching the URL: http: // ([w-] +.) + [w-] + (/[w -./? % & =] *)?
Algorithm program that uses regular expressions to remove repeated characters in a string:
Use a regular expression to extract a javascript program with a file name from a URL. the following result is page1.
Use regular expressions to restrict text box input in a webpage form:
You can only enter Chinese characters using regular expressions:
You can only enter full-width characters using regular expressions:
You can only enter numbers using regular expressions:
You can only enter numbers and English letters using regular expressions:
[U4e00-u9fa5] match double byte characters (including Chinese characters): [^ x00-xff] application: calculate the length of a string (a double byte character length meter 2 ,...