Difference between revisions of "StringReplace"

From Catglobe Wiki
Jump to: navigation, search
Line 1: Line 1:
 
  
 
  
  
==== stringReplace ====
+
==== stringReplace ====
  
Replaces all occurrences of a substring in a string with another string, then returns the new string
+
Replaces all occurrences of a substring in a string with another string, then returns the new string  
  
'''Syntax'''
+
'''Syntax'''  
stringReplace(''main_str'', ''old_subStr'', ''new_subStr'')
 
  
'''Arguments'''
+
stringReplace(''main_str'', ''old_subStr'', ''new_subStr'')
''main_str'': Is a string expression.''old_subStr'': Is a string expression.''new_subStr'': Is a string expression.
 
  
'''Return type'''
+
'''Arguments'''  
string
 
  
'''Examples'''
+
''main_str'': Is a string expression.''old_subStr'': Is a string expression.''new_subStr'': Is a string expression.
string main_str = "The fox was hunting for a rabbit.";string old_subStr = "hunting for";string new_subStr = "hunted by";string new_str = stringReplace(main_str, old_subStr, new_subStr);print(main_str);print(new_str);
+
 
 +
'''Return type'''
 +
 
 +
string
 +
 
 +
'''Examples'''  
 +
 
 +
string main_str = "The fox was hunting for a rabbit.";string old_subStr = "hunting for";string new_subStr = "hunted by";string new_str = stringReplace(main_str, old_subStr, new_subStr);print(main_str);print(new_str);  
 +
 
 +
'''Availability'''
  
'''Availability'''
 
 
Version 4.8  
 
Version 4.8  
  
 
[[Category:String_Functions]]
 
[[Category:String_Functions]]

Revision as of 04:36, 14 December 2011



stringReplace

Replaces all occurrences of a substring in a string with another string, then returns the new string

Syntax

stringReplace(main_str, old_subStr, new_subStr)

Arguments

main_str: Is a string expression.old_subStr: Is a string expression.new_subStr: Is a string expression.

Return type

string

Examples

string main_str = "The fox was hunting for a rabbit.";string old_subStr = "hunting for";string new_subStr = "hunted by";string new_str = stringReplace(main_str, old_subStr, new_subStr);print(main_str);print(new_str);

Availability

Version 4.8