[DGD] string parsing..

Nico Lammers n.lammers at home.nl
Thu Sep 27 19:26:15 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);

Umm, yeah, I figured that it could be done easier.. or even more
efficiently,
as you state.

But now I still don't know how to use parse_string() ;-)

It seemed to me that the examples I gave would be easy to do.. but maybe
I'm wrong?

-- Nico Lammers

_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list