Analysis on character locating using PHP Regular Expressions

Source: Internet
Author: User

We often encounter the use of PHP regular expressions to locate characters during development. What types of characters does a PHP regular expression have? What exactly do they represent? Let's start introducing them one by one.

PHP Regular Expressions:

A PHP regular expression is a very important character in a PHP regular expression. It is used to describe the position of a character in a matching object.

The PHP Regular Expression locates the types and meanings of characters:

◆ ^:

Indicates that the matching mode appears at the beginning of the matching object (different from that in)

◆ $:

Indicates that the matching mode appears at the end of the matching object.

◆ Space:

Indicates that the matched pattern appears at one of the two boundaries at the beginning and end.

◆ "/^ He /":

It can match strings starting with "he", such as hello and height;

◆ "/He $ /":

It can match strings ending with "he", that is, "she;

◆ "/He /":

It starts with a space and matches a string starting with "he", just like ^;

◆ "/He /":

End with a space. It matches the string ending with "he", just like "$;

◆ "/^ He $ /":

It indicates that it only matches the string "he.

The following is a brief introduction to the location of PHP regular expressions. I hope you can understand and understand the location of PHP regular expressions.


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.