Dynamic Web pages make PHP regular expressions commonly used

Source: Internet
Author: User
Tags html tags numeric value regular expression

A regular expression that matches a Chinese character: [U4e00-u9fa5] matches double-byte characters (including Chinese characters): [^x00-xff] Apply: Computes the length of a string (a double-byte character length meter, 2,ascii character count 1)

A regular expression that matches a blank row: [s|] * Regular expressions that match HTML tags:/< (. *) >.*|< (. *)/>/regular expressions that match the trailing spaces: (^s*) | (s*$) Application: JavaScript does not have a trim function like VBScript, we can use this expression to implement, as follows:

Using regular expressions to decompose and transform IP addresses: The following is a JavaScript program that uses a regular expression to match an IP address and converts an IP address to a corresponding numeric value:

However, if the above program does not use a regular expression, and the split function directly to decompose may be simpler, the program is as follows:

Regular expression matching an email address: w+ ([-+.] w+) *@w+ ([-.] w+) *.w+ ([-.] w+) * Matching the URL of the regular expression: http://([w-]+.)  +[w-]+ (/[w-/?%&=]*)? An algorithmic program that uses regular expressions to remove repetitive characters from a string:

JavaScript program that extracts the filename from the URL address using a regular expression, the following result is Page1

Use regular expressions to restrict text box entry in a Web page form: Restrict the use of regular expressions to only Chinese:

Only full-width characters can be entered with regular expression restrictions:

Only numbers can be entered with regular expression restrictions:

You can only enter numbers and English with regular expression restrictions:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.