Php Regular Expression suffix

Source: Internet
Author: User

Perl-style Regular Expressions allow you to place a single character option (FLAG) behind the regular expression mode to modify the matching interpretation or behavior. For example, to perform case-insensitive matching, you can simply use the I flag:
Preg_match ('/cat/I', 'Stop, Catherine! '); // Returns true if returns is true.
Table 4-12 shows the modifiers from Perl supported in Perl-Compatible Regular Expressions:
Table 4-12: Perl flag

Modifier Yi
/Regexp/I Case-insensitive matching
/Regexp/s Match a period (.) to any character, including a line break (\ n)
/Regexp/x Remove blank spaces and comments from the Mode
/Regexp/m Make ^ match the content after the line break (\ n), the dollar sign ($) matches the content before the line break (\ n)
/Regexp/e If the replacement string is a PHP code, run eval () to obtain the actual replacement string.
PHP's Perl-Compatible Regular Expression functions also support other modifiers not supported in Perl, as shown in Table 4-13:
Table 4-13: Other PHP flags
Modifier Yi
/Regexp/U Reverse the greed of sub-models; * match as few as possible with + rather than as much as possible.
/Regexp/u Treat pattern strings as UTF-8 Encoding
/Regexp/X If a backslash is followed by a character with no special meaning, an error is generated.
/Regexp/ Position the anchor at the beginning of the string as if there is a ^ in the pattern.
/Regexp/D Make $ match the end of only one line
/Regexp/S Make the expression parser more careful to check the structure of the mode, so that the second Runtime (such as in a loop) speeds up
 

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.