note 26116 deleted from ref.regex by googleguy

From: Date: Tue, 22 Oct 2013 09:04:21 +0000
Subject: note 26116 deleted from ref.regex by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196882@lists.php.net to get a copy of this message
Note Submitter: moc DOT liamtoh AT ssengnorw ---- In a PCRE \s matches whitespace, but not inside a character class: preg_match ('/\s/', ' ') // match preg_match ('/[\s]/', ' ') // no match Within a character class [:space:] is treated as a single character that matches any single whitespace character: $pattern = '/[[:space:]]/'; $subject = "space tab\tnewline\n"; preg_match_all($pattern, $subject, $out) // == 3 To match a hyphen from within a character class, it must either be first or last; otherwise, it will act as a range operator. Example: To match a blank string or a string containing only uppercase letters, underscores, spaces, and hyphens: preg_match('/^[A-Z_ -]*$/', $subject) To match any whitespace, not just spaces: preg_match('/^[A-Z_[:space:]-]*$/', $subject)

« previous php.notes (#196882) next »