> >I think I'm looking for something like this:
> 
> $dirnamewanted = ereg_replace("^[[:alnum:]]+$"
> $_POST['dirnamewanted']);
> 
> 
> Problem is that this crashes my script.  I am so tired of this thing...
> 
> Marian - as someone else already mentioned, it may not be a good idea to
> automagically change a value provided by the user, unless there's no
> reason for the user to ever know the modified value....
> 
> That said, if you really want to use ereg_replace, try this:
> 
> ereg_replace("[^[:alnum:]+$]", "", $_POST['dirnamewanted']);
> 
> (note: placed ^ and +$ inside bounding brakcets, added replace string,
> separated parms with commas)
> 
> Mike


You probably don't want the $ after the + sign.  This anchors the match to the
end of the string so only illegal characters at the end would be replaced. 
Otherwise, the movement of the carat to between the opening square brackets and
adding the commas and replacement string are all on target.

Another important factor is that ereg_replace() returns the altered string
through the function name:

$new = ereg_replace($regex, $replace_with, $old);

so your code should reflect this.  The preg* functions work differently.

James
_____

James D. Keeline
http://www.Keeline.com  http://www.Keeline.com/articles
http://Stratemeyer.org  http://www.Keeline.com/TSCollection

http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Summer Semester Begins Jun 20 -- New Classes Start Every Few Weeks.


------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12huc0i30/M=362131.6882499.7825260.1510227/D=groups/S=1705005703:TM/Y=YAHOO/EXP=1123530403/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to