Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: ereg_replace()


Message #1 by "Srinivasan Ramakrishnan" <srinivar@m...> on Fri, 29 Dec 2000 02:34:24 +0530
Hi,

The problem is that PHP produces error messages whenever I run this
function. I thought it would be something basic, since I'm not familiar with
the ereg_ functions.

Anyway it should work but it doesn't. It doesn't matter that invalid
characters exist, as long as I can remove them. This is a script that will
run over a large bunch of files, and not really user feedback based.

I have a feeling I'm doing something not idiomatic here. I'm not too happy
with the solution, I would like to find a cleaner solution. One that doesn't
involve parsing the string char by char!

I guess a switch case checking char by char would be easy and do the job,
but I wanted a cleaner solution.


-Srini






----- Original Message -----
From: Adam Lang <aalang@r...>
To: professional php <pro_php@p...>
Sent: Friday, December 29, 2000 7:03 PM
Subject: [pro_php] Re: ereg_replace()


: Also, you may be giving yourself more headaches.  It might be easier to
: check for invalid characters and reject the name if found and ask for a
: proper one to be inputed.
:
: Adam Lang
: Systems Engineer
: Rutgers Casualty Insurance Company
: http://www.rutgersinsurance.com
:
: ----- Original Message -----
: From: "Srinivasan Ramakrishnan" <srinivar@m...>
: To: "professional php" <pro_php@p...>
: Sent: Thursday, December 28, 2000 4:04 PM
: Subject: [pro_php] ereg_replace()
:
:
: > I seem to be having problems with this function::
: >
: >
: > function validFileName($name){
: > // Will return a string containing a valid windows filename
: > // Invalid characters are /\:*?"<>|
: > // Invalid characters will be removed
: >
: >  $name = ereg_replace("/","",$name);
: >  $name = ereg_replace("\\","",$name);
: >  $name = ereg_replace(":","",$name);
: >  $name = ereg_replace("*","",$name);
: >  $name = ereg_replace("?","",$name);
: >  $name = ereg_replace("\"","",$name);
: >  $name = ereg_replace("<","",$name);
: >  $name = ereg_replace(">","",$name);
: >  $name = ereg_replace("|","",$name);
: >
: >  return $name;
: > }
: >
: > Please help.
: >
: >
: > -Srini


--- 
NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS?  Is FREE okay?
Visit EarthWeb for the latest in IT Management, Software Development, 
Web Development, Networking & Communications, and Hardware & Systems.  
Click on http://www.earthweb.com for FREE articles, tutorials,
and discussions from the experts.
---
You are currently subscribed to pro_php as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-pro_php-$subst('Recip.MemberIDChar')@p2p.wrox.com

  Return to Index