note 78417 added to function.preg-match
| From: | erandra at gmail dot com | Date: | Thu, 11 Oct 2007 07:39:52 +0000 |
| Subject: | note 78417 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131295@lists.php.net to get a copy of this message | ||
Here is a sample code to check for alphabetic characters only with an exception to space, hyphen and
single quotes using preg_match().
$alpha = "some very funny string'9-2'";
/* check for alphabets and hyphens, quotes and space in the string but no numbers */
if(preg_match("/^[a-zA-Z\-\'\ ]+$/u", $alpha)){
return 1;
}else
return 0;
one can just add a '\' followed by the character he wish to allow for use [\@].
i hope it would be helpful to some one their.
-Erandra
----
Server IP: 203.16.234.90
Probable Submitter: 124.254.118.3
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- https://master.php.net/note/edit/78417
Del: integrated -- https://master.php.net/note/delete/78417/integrated
Del: useless -- https://master.php.net/note/delete/78417/useless
Del: bad code -- https://master.php.net/note/delete/78417/bad+code
Del: spam -- https://master.php.net/note/delete/78417/spam
Del: non-english -- https://master.php.net/note/delete/78417/non-english
Del: in docs -- https://master.php.net/note/delete/78417/in+docs
Del: other reasons-- https://master.php.net/note/delete/78417
Reject -- https://master.php.net/note/reject/78417
Search -- https://master.php.net/manage/user-notes.php