Learning Regular Expressions in php and learning Regular Expressions in php

Source: Internet
Author: User

Learning Regular Expressions in php and learning Regular Expressions in php

Syntax format:Between the delimiters.

1 Common metacharacters include "+", "*", and "?".

Where,

The "+" metacharacter specifies that its leading character must appear one or more times consecutively in the target object,

The "*" metacharacter specifies that its leading character must appear zero or multiple times in the target object,

And "?" Metacharacter specifies that the leading object must appear zero or once consecutively in the target object.

1/jim {}/<br/> 2 the above regular expression specifies that the character m can appear 2-6 times consecutively in the matching object. Therefore, the above regular expression can match strings such as jimmy or jimmmmmy. <Br/> 3. After learning about how to use regular expressions, let's take a look at the usage of several other important metacharacters. <Br/> 4 \ s: Used to match a single space character, including the tab key and line break; <br/> 5 \ S: Used to match all characters except a single space character; <br/> 6 \ d: Used to match numbers ranging from 0 to 9; <br/> 7 \ w: Used to match letters, numbers, or underline characters; <br/> 8 \ W: Used to match all characters that do not match \ w. <br/> 9.: Used to match all characters except line breaks. <Br/>

In addition:

Commonly used positioning characters include "^", "$", "\ B", and "\ B ".

The "^" Locator specifies that the matching mode must start with the target string,

The "$" operator specifies that the matching mode must appear at the end of the target object,

The \ B locator specifies that the matching mode must appear at either the beginning or end of the target string,

The "\ B" Locator specifies that the matched object must be within the boundary of the start and end of the target string. That is, the matched object cannot start with the target string, it cannot end with the target string.

 

Matches a specified range, not limited to specific characters. For example:

/[A-Z]/
The above regular expression will match any uppercase letter from A to Z.
/[A-z]/
The above regular expression will match any lowercase letter from a to z.
/[0-9]/
The above regular expression will match any number from 0 to 9.
/([A-z] [A-Z] [0-9]) +/

 


Which regular expression should php learn?

Asked the younger brother. Asp.net has regular expressions, js also has regular expressions, and php also has regular expressions (php seems to be a Perl-Compatible Regular Expression ). Therefore, these regular expressions seem to be a bit the same. I want to ask if the syntax of "all" regular expressions is the same? Or are there several different regular expressions? What kind of regular expression should I learn in php? Do you want to learn Regular Expressions compatible with Perl. What is a Perl-Compatible Regular Expression? (I hope you can give me a good link to learn php regular expressions.) Thank you very much !!!

How to Learn php Regular Expressions

In fact, you don't need to learn.
At the beginning, let's take a rough look. Then, wait for the specific usage. What the regular expression can do is that string functions can basically

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.