$str = eregi_replace("[^[_a-z0-9-]]", '_', $str)

would this 2-seconds written-in, non-tested scratch of code do the job?

If not then something like this...

eregi_replace() is what you are looking for.



Sincerely, 

 Maxim Maletsky
 Founder, Chief Developer
 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com




-----Original Message-----
From: Sean Coyle [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 18, 2001 2:23 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Is it possible to parse a variable by character?


Hey there guys,

    This may seem like a dumb question, but I have to ask it anyway.

I have a form in one of my php based scripts that allows for file uploads.
I recently noticed a potential issue if people upload files containing
anything else but the standard characters ([_a-z0-9-]+(\.[_a-z0-9-]).

    I am not sure if this can be done, but what I need to do is parse this
variable (lets call it $file_name) by character looking for anything save
letters a-z (A-Z) and numbers 0-9.  Any arrangements of numbers, letters and
full stops (.) are to be permitted, and if any character does not meet those
specifications, that single character should be converted to an underscore.

    Any ideas on how I can go about doing something like this?

BTW: (Some background info)  I examined the average validate e-mail idea,
however, rather than reject the string, I would like to be able to 'replace'
the offending character.

Thanks in advance,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to