String :: replace - Replace specified string or text range by new string
The function replaces the string sOld with the string sNew and returns a reference to this string. .
The coding type of the result depends on the string coding type of the calling string. When encoding types of the strings differ, copies of strings passed in sOld and/or sNew are recoded to the encoding type of the calling string before performing the operation..
odaba::String str = "odaba Database";
str.replace("da","?",false);
// str == "o?ba ?tabase"
odaba::String str = "xxxxxx";
str.replace("xx","x");
// str == "xxx"
Implementation overview
- Replace all string occurences case sensitive
String :: replace ( sOld, sNew ) - Replace all string occurences
String :: replace ( sOld, sNew, bCaseSensitive ) - Replace first occurence
String :: replace ( iPosition, sOld, sNew, bCaseSensitive )
Implementation details
-
Replace all string occurences case sensitive
odaba::String & String  :: replace ( odaba::String &sOld, odaba::String &sNew )
The function replaces all occurrence of the string value passed in sOld with the string value passed in sNew and returns a reference to this string. The replacement text is not rescanned after it is inserted, i.e. replacing does not work recursively. The search is case sensitive.
When sOld is empty, the function throws an exception.
- sOld - Old string value
- sNew - New string value
to list
-
Replace all string occurences
odaba::String & String  :: replace ( odaba::String &sOld, odaba::String &sNew, bool bCaseSensitive )
The function replaces all occurrence of the string value passed in sOld with the string value passed in sNew and returns a reference to this string. The replacement text is not rescanned after it is inserted, i.e. replacing does not work recursively. When bCaseSensitive is true (default), the search is case sensitive; otherwise the search is case insensitive.
When sOld is empty, the function throws an exception.
- sOld - Old string value
- sNew - New string value
- bCaseSensitive
- Case sensitive option
The option indicates case sensitive data in text ( true )
to list
-
Replace first occurence
odaba::String & String  :: replace ( int32 iPosition, odaba::String &sOld, odaba::String &sNew, bool bCaseSensitive )
The function replaces the first occurrence of the string sOld with the string value passed in sOld with the string value passed in sNew beginning at position passed in iPosition (units). When the specified position exceeds the string length, nothing is replaced.
When bCaseSensitive is true (default), the search is case sensitive; otherwise the search is case insensitive.
When iPosition is negative or sOld is empty, the function throws an exception.
- iPosition
- Position in collection
The position of an element in a collection is beginning with 0 for the first element.
- sOld - Old string value
- sNew - New string value
- bCaseSensitive
- Case sensitive option
The option indicates case sensitive data in text ( true )
to list
- iPosition
- Position in collection