string_replace

Returns a copy of a string with the first instance of a given substring replaced with a new substring.

Syntax:

GML Code Example

string_replace(str, substr, newstr);


Argument Description
str The string to be copied.
substr The substring within the string to be replaced.
newstr The new substring to replace the previous one.


Returns: String


Description

You can use this function to parse a string looking for a specific part, which can then be replaced by the new string that you have specified.


Example:

GML Code Example

str1 = 'Hello Earth';
 str2 = string_replace(str1, 'Earth', 'World');

This will set str2 to str1, but with its instance of 'Earth' replaced with 'World', resulting in str2 being 'Hello World'.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here