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