Full Manual of regular expressions for PHP tutorials
Objective
Regular expressions are cumbersome, but powerful, learned applications will give you an absolute sense of accomplishment in addition to improving efficiency. It is not a problem to master regular expressions, as long as you read them carefully, add some references when applying them.
Index
1._ Intro
2._ The history of regular expressions
3._ Regular Expression definitions
3.1_ Ordinary characters
3.2_ non-printable characters
3.3_ Special Characters
3.4_ Qualifier
3.5_ Locator
3.6_ selection
3.7_ Back To reference
4._ operator precedence for various operators
5._ all symbols Explained
6._ Partial examples
7._ Regular expression matching rules
7.1_ Basic Pattern matching
7.2_ character clusters
7.3_ to confirm recurring occurrences
1. Intro
At present, regular expression has been widely used in many software, including *nix (Linux, UNIX, etc.), HP and other operating systems, Php,c#,java and other development environments, as well as many applications, can see the shadow of the regular expression.
The use of regular expressions can be achieved through a simple approach to powerful functions. In order to be simple and effective without losing strong, resulting in regular expression code difficult, learning is not very easy, so need to pay some effort to do, after the introduction of reference to certain references, use up or relatively simple and effective.
Example: ^.+@.+. +$
This kind of code used to scare me a lot. Maybe a lot of people are scared to run away by this kind of code. Continuing to read this article will allow you to freely apply such code.
Note: The 7th part here looks somewhat repetitive, with the intention of re-describing the sections in the previous table to make the content easier to understand.
2. History of regular expressions
The "ancestors" of regular expressions can be traced back to early studies of how the human nervous system works. Warren McCulloch and Walter Pitts the two neuroscientists have developed a mathematical approach to describe these neural networks.
In 1956, a mathematician named Stephen Kleene, on the basis of the early work of McCulloch and Pitts, published a paper titled "Representation of Neural network events", introducing the concept of regular expressions. The regular expression is the expression that describes what he calls "the algebra of the regular set", so the term "regular expression" is used.
Later, it was discovered that this work could be applied to some early studies of the computational search algorithm using the Ken Thomps tutorial on, and Ken Thompson was the main inventor of Unix. The First Utility application of a regular expression is the QED Editor in Unix.
As they say, the rest is a well-known history. Since then, regular expressions have been an important part of text-based editors and search tools.
3. Regular expression definitions
The regular expression (regular expression) describes a pattern of string matching that can be used to check whether a string contains a seed string, replaces a matched substring, or extracts a substring that matches a certain condition from a string.
When a directory is listed, the *.txt in dir *.txt or LS *.txt is not a regular expression, because the meaning of * is different from the regular type.
Regular expressions are text patterns that consist of ordinary characters, such as characters A through z, and special characters (called metacharacters). A regular expression, as a template, matches a character pattern to the string you are searching for. 1 2 3) 4 5
http://www.bkjia.com/PHPjc/632309.html www.bkjia.com true http://www.bkjia.com/PHPjc/632309.html techarticle the regular expression of the PHP tutorial full manual Preface the regular expression is cumbersome, but powerful, learned after the application will let you in addition to improve efficiency, will bring you the absolute sense of accomplishment ...