Page 1 of 1

Only letting some chars though

Posted: Sat Aug 19, 2006 1:18 am
by shiznatix
Hey hey! Ok so I just want to know if this will work. I want to only let A-Z a-z 0-9 . - and _ though. so I think its something like this...

Code: Select all

$filename = preg_replace('#[^A-Za-z0-9\.\-_]#', $filename);
am I missing anything?

Posted: Sat Aug 19, 2006 1:21 am
by RobertGonzalez
Test it at RegExpLib.

EDIT | Corrected incorrect edit.

Posted: Sat Aug 19, 2006 1:27 am
by feyd
missing third argument.

Posted: Sat Aug 19, 2006 1:39 am
by shiznatix
feyd wrote:missing third argument.

Code: Select all

$replace = '';
$filename = preg_replace('#[^A-Za-z0-9\.\-_]#m', $replace, $filename);
like so? I added the multi-line reader thing but its a filename so can filenames actually contain a line break?