string/Replace

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=Replace |Parent=string |Description=Replaces all occurrences of the supplied second string. |Realm=Shared |IsClass=No }} {{Arg |type=string |name=str |de...")
 
(wrong description)
Line 23: Line 23:
 
{{Ret
 
{{Ret
 
|type=string
 
|type=string
|desc= string
+
|desc=string
 
}}
 
}}
 
{{Example
 
{{Example
| Description = Number to be converted.
+
|Description=Replaces the word "Garrys" by "Hers".
| Code =
+
|Code=local text = "Garrys Mod"
local text = "Garrys Mod"
+
 
print(string.Replace(text, "Garrys", "Hers"))
 
print(string.Replace(text, "Garrys", "Hers"))
| Output = <br/>
+
|Output=<br/>
 
Hers Mod
 
Hers Mod
 
}}
 
}}

Revision as of 18:46, 18 January 2015

 string.Replace( )

Contents

Description

Replaces all occurrences of the supplied second string.

Arguments

string str

The string we are seeking to replace an occurrence(s).

Arguments

string find

What we are seeking to replace.

Arguments

string replace

What to replace find with.

Returns

string

string

Examples

Example

Replaces the word "Garrys" by "Hers".

local text = "Garrys Mod"
print(string.Replace(text, "Garrys", "Hers"))

Output:


Hers Mod
Personal tools
Navigation