php regular specified string content preg_match function description

Source: Internet
Author: User
Keywords Network programming PHP tutorial
Tags .mall code content expression function network network programming php

php tutorial Regularly specify the contents of the string Preg_match function description Although the code is small, but the code is as simple as the following:

preg_match ('/ ^ (?! string) /', 'aa') === true This is used to verify that a string is not 'string'
In perl or regular expressions that support perl (such as php), you can do this with a look-ahead declaration, which is:
The code is as follows:

preg_match ('/.* (?!. txt) $ /', 'aa') Means to match all names that do not end in .txt


preg_match - Perform regular expression matching instructions
int preg_match (string pattern, string subject [, array matches [, int flags]])


Search in the subject string for the pattern matching the regular expression.

If matches is provided, it will be filled by the result of the search. $ matches [0] will contain the text that matches the entire pattern, $ matches [1] will contain the text that matches the subpattern in the first captured bracket, and so on

Related Article

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.