summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fbasicstring.h22
-rw-r--r--src/unit/fstring.unit7
2 files changed, 29 insertions, 0 deletions
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
1035 core->clear(); 1035 core->clear();
1036 } 1036 }
1037 1037
1038 MyType replace( const MyType &fnd, const MyType &rep ) const
1039 {
1040 MyType out;
1041 const_iterator o = begin();
1042 while( true )
1043 {
1044 const_iterator i = o.find( fnd );
1045 if( !i )
1046 {
1047 out.append( o );
1048 return out;
1049 }
1050 else
1051 {
1052 out.append( o, i );
1053 out.append( rep );
1054 o = i;
1055 o += fnd.getSize();
1056 }
1057 }
1058 }
1059
1038 /** 1060 /**
1039 * Force the string to resize 1061 * Force the string to resize
1040 *@param nNewSize (long) The new size of the string. 1062 *@param nNewSize (long) The new size of the string.
diff --git a/src/unit/fstring.unit b/src/unit/fstring.unit
index d218a07..2f2eb69 100644
--- a/src/unit/fstring.unit
+++ b/src/unit/fstring.unit
@@ -333,3 +333,10 @@
333 unitTest( b == "Goodbye" ); 333 unitTest( b == "Goodbye" );
334} 334}
335 335
336{%replace1}
337{
338 Bu::FString a;
339 a = "This is a test.";
340 unitTest( a.replace("i", "ooo") == "Thooos ooos a test." );
341}
342