Dynamic Web pages make PHP regular expressions commonly used

Source: Internet
Author: User

Matching regular expressions for Chinese characters: [\U4E00-\U9FA5]

Match Double-byte characters (including Chinese characters): [^\x00-\xff]

Application: Computes the length of the string (a double-byte character length meter 2,ascii character 1)

A regular expression that matches a blank row: \n[\s]*\r

Regular expression matching HTML tags:/< (. *) >.*<\/>< (. *) \/>/

Matching a regular expression with a trailing space: (^\s*) (\s*$)

Application: JavaScript does not have a trim function like VBScript, we can use this expression to implement, as follows:

To decompose and transform an IP address using a regular expression:

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:

1 2 Next page > full text reading tips: Try "←→" button, turn the page more convenient Oh!

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.