Toggle menu
913
3.8K
30.2K
279.2K
Catglobe Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

StringReplace: Difference between revisions

From Catglobe Wiki
Cg_pham (talk | contribs)
No edit summary
Cg van (talk | contribs)
No edit summary
Ā 
(One intermediate revision by one other user not shown)
Line 1: Line 1:

{{HelpFiles}}


==== stringReplaceĀ  ====
==== stringReplaceĀ  ====
Line 19: Line 19:
'''Examples''' Ā 
'''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); Ā 
''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); //Result: The fox was hunting for a rabbit.''
Ā 
''print(new_str); //Result: The fox was hunted by a rabbit. ''


'''Availability''' Ā 
'''Availability''' Ā 

Latest revision as of 03:24, 23 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); //Result: The fox was hunting for a rabbit.

print(new_str); //Result: The fox was hunted by a rabbit.

Availability

Version 4.8