Php knowledge review regular expressions // technical knowledge of regular expressions // [] defining character sets and example [a-z] [A-Z] [0-9] [\ f \ r \ n \ t] // positioning character ^ [A-Z] [0-9] $ start and end // quantifiers * +? {N} {m, n} {n.} indicates the number of repetitions. // select | // printable character: regular expression for reviewing ASCII php knowledge points
// Technical knowledge of regular expressions
// [] Define character set and example [a-z] [A-Z] [0-9] [\ f \ r \ n \ t]
// Positioning character ^ [A-Z] [0-9] $ beginning and end
// Quantifiers * +? {N} {m, n} {n.} indicates the number of duplicates.
// Select |
// Printable character: the 33-127 character in ASCII, which is the space, deletion, carriage return, and cancellation characters that we can see.
// POSOX regular expression
// Common functions
Echo"
";
$ B4 = "abc ";
$ Pattern = "[[: alpha:]";
Echo ereg ($ pattern, $ b4 );
// Output 1
// Eregi () unsigned
$ B7 = "asd & ass @ ass & adfdf ";
$ Pattern1 = "&";
$ Pattern2 = "[& @]";
Print_r (split ($ pattern1, $ b7 ));
Print_r (split ($ pattern2, $ b7 ));
Echo"
";
$ B8 = "helloworld ";
$ Pattern3 = "world ";
$ Replacement1 = "persion ";
Echo ereg_replace ($ pattern3, $ replacement1, $ b8 );
Echo"
";
Echo SQL _regcase ("abcdefg ");
// Output: [Aa] [Bb] [Cc] [Dd] [Ee] [Ff] [Gg]
// Perl regular expression perl is an extra extended \ d number \ D non-digit \ s blank \ S non-blank \ w letter mathematical symbol underline \ W non-letter number on the basis of posix underline
// Common functions: array preg_grep (string pattern, array input)
Echo"
";
$ W1 = array ("adad", "adad4", "asda", "1asf3", "sdfs ");
$ Fl_array = preg_grep ("/^ \ D {1, }$/", $ w1); // emphasize {1 here,} instead of {1.} in posix .}
Print_r ($ fl_array );
Echo"
";
Echo preg_match ("/a/", "abc ");
// Output 1
Echo"
";
// \ B indicates the word boundary
If (preg_match ("/\ bweb \ B/I", "PHP is the web scripting language of choice .")){
Print "A match was found .";
} Else {
Print "A match was not found .";
}
If (preg_match ("/\ bweb \ B/I", "PHP is the website scripting language of choice .")){
Print "A match was found .";
} Else {
Print "A match was not found .";
}
// Especially when matching email addresses
Echo"
";
$ Pattern5 = "/[\ *] + /";
$ W3 = "aaa *** bbb * ccc ";
Print_r (preg_split ($ pattern5, $ w3 ));
Echo"
";
$ Pattern6 = "/world /";
$ Content2 = "girl ";
$ Tre = "hello world ";
Echo preg_replace ($ pattern6, $ content2, $ tre );
// String preg_quote (string str [, string delimiter]) escape
Echo"
";
$ Keywords = "$40 for a g3/400 ";
$ Keywords = preg_quote ($ keywords, "/"); // if this field is not added, it will not escape/in g3/400 /;
Echo $ keywords;