Modified mode: http://www.phpx.com/man/en/pcre.pattern.modifiers.html
Mode grammar: http://www.phpx.com/man/en/pcre.pattern.syntax.html
Special characters of regular expressions include. // *? [^] $ () {} =! <> |:.
/ Have a universal escap of several uses
^ Assert the beginning of the target (or starting at the beginning of multi-line mode, that is, followed by a changeman)
The end of the assertion target (or the end of the multi-line mode, that is, before changing the line)
Matching any of the characters outside the commutation (by default)
[Character class definition "
] Character class definition end
| Start a multi-selection branch
(Sub-mode start
) End of sub mode
• Expansion (meaning, 0 or 1 quantity qualifier, and quantity qualifier minimum)
* Match 0 or more quantity qualifiers
Match 1 or more quantity qualifiers
{Minimum / maximum quantity
} At least a maximum quantity limit
The part in the middle parentheses is called "character class". The figures available in the character class are:
/ Universal escape character
^ Exclude the character class, but only when it is the first character
- Indicates the range of characters
] End Character class
Some special characters:
/ A a a a a a a a a a a a a a a alarm (0x07)
/ cx "control-x", where x is arbitrary characters
/ e escape (0x1b)
/ f converted FormFeed (0x0c)
/ N newline NEWLINE (0x0a)
/ R Enter Carriage Return (0x0D)
/ T tabletter Tab (0x09)
/ xhh hexadecimal code for hh characters
/ DDD octal code is character, or backreference
/ 040 another method of means space
011 always represents tabs Tab
/ d any 10
/ D any one-way character character
/ s any blank character
/ S any non-blank character
/ W any "word" character
/ W An "non-word" character
Regular expression
Reverse reference method: // 1 or / $ {1}
$ String = "April 15, 2003"; $ PATTERN = "/ (/ w ) (/ d ), (/ d ) / i"; $ replacement = "/ $ {1} 1, / $ 3"; Print preg_replace $ Pattern, $ Replacement, $ String); / * Output ====== April1, 2003 * /?>