This article introduces, with the PHP regular area with "ABC" beginning, and can not be "xyz" end of the string method, the need for a friend reference. Requirements: Use the PHP regular expression match to start with "ABC", but the end cannot contain the string "X", "Y", "Z". Parsing: ABC begins with a regular write: ^abc. Start with ABC, followed by a string of strings commonly used in the [^ ...] To deny it. Since it is the negation of "X", "Y", "Z", it is [^xyz]. The complete regular expression is this: ^abc[^xyz]*$The following is a full PHP example that uses this regular, as follows:
';} else {echo $str. ' Does not meet ';} The output abcdef124f complies with $STR = ' abcdef12x124 ', if (Preg_match ($search, $str)) {echo $str. ' Compliant ';} else {echo $str. ' Does not meet ';} Output abcdef12x124 does not conform to//edit by bbs.it-home.org?> |