From 1f894ce98811eb8a2ab893db6c2d53cd77a111e7 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 24 Nov 2009 04:39:06 +0000 Subject: Added a replace function to fstring...sweeet. --- src/fbasicstring.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/fbasicstring.h') diff --git a/src/fbasicstring.h b/src/fbasicstring.h index 0e63efe..1c1f8a2 100644 --- a/src/fbasicstring.h +++ b/src/fbasicstring.h @@ -1035,6 +1035,28 @@ namespace Bu core->clear(); } + MyType replace( const MyType &fnd, const MyType &rep ) const + { + MyType out; + const_iterator o = begin(); + while( true ) + { + const_iterator i = o.find( fnd ); + if( !i ) + { + out.append( o ); + return out; + } + else + { + out.append( o, i ); + out.append( rep ); + o = i; + o += fnd.getSize(); + } + } + } + /** * Force the string to resize *@param nNewSize (long) The new size of the string. -- cgit v1.2.3