note 101575 added to function.preg-match
| From: | ian_channing at hotmail dot com | Date: | Mon, 27 Dec 2010 09:55:50 +0000 |
| Subject: | note 101575 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175214@lists.php.net to get a copy of this message | ||
When trying to check a file path that could be windows or unix it took me quite a few tries to get
the escape characters right.
The Unix directory separator must be escaped once and the windows directory separator must be
escaped twice.
This will match path/to/file and path\to\file.exe
preg_match('/^[a-z0-9_.\/\\\]*$/i', $file_string);
----
Server IP: 217.71.118.186
Probable Submitter: 80.200.227.91
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- https://master.php.net/note/edit/101575
Del: integrated -- https://master.php.net/note/delete/101575/integrated
Del: useless -- https://master.php.net/note/delete/101575/useless
Del: bad code -- https://master.php.net/note/delete/101575/bad+code
Del: spam -- https://master.php.net/note/delete/101575/spam
Del: non-english -- https://master.php.net/note/delete/101575/non-english
Del: in docs -- https://master.php.net/note/delete/101575/in+docs
Del: other reasons-- https://master.php.net/note/delete/101575
Reject -- https://master.php.net/note/reject/101575
Search -- https://master.php.net/manage/user-notes.php