In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Jtjohnston) wrote:
> Suggestions for improvement anyone?
> > > $mystring = ereg_replace (".html", "", $mystring);
> > > $mystring = ereg_replace (".htm", "", $mystring);
> > > $mystring = ereg_replace (" ", "", $mystring);
> > >
> > > $mystring = ereg_replace ("}", "", $mystring);
> > > $mystring = ereg_replace ("{", "", $mystring);
> > > $mystring = ereg_replace ("\|", "", $mystring);
> > > $mystring = ereg_replace ("\]", "", $mystring);
> > > $mystring = ereg_replace ("\[", "", $mystring);
> > > $mystring = ereg_replace ("\\\\", "", $mystring);
<snip much, more of same>
Since you ask...
You can save yourself a lot of trouble and a ton of wasted function calls
by checking out a POSIX (ereg_*) or PCRE (preg_*) syntax tutorial. When
you want to match space or punctuation characters, character classes are a
Good Thing(TM). That whole loooooong block of code could be rendered with
a single good, concise regex. With the bonus of a lot less escaping.
--
CC
--
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]