[DGD] string parsing..

Erwin Harte harte at xs4all.nl
Thu Sep 27 19:14:26 CEST 2001


On Thu, Sep 27, 2001 at 07:08:28PM +0200, Nico Lammers wrote:
> Speaking of parse_string()...
> 
> Could anyone give me a few (basic) examples of using it?
> I guess we can use it to search a string for a substring, or replace a
> substring
> or something?

Sure, but for non-regexp that's much more efficiently done using
explode() and implode().

  string str; /* Original string */
  string sub; /* Substring you're looking for */
  string rep; /* What you want to replace sub with */

  str = implode(explode(sub + str + sub, sub), rep);

Erwin.
-- 
Erwin Harte <harte at xs4all.nl>
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list