string.gsub

From GMod Wiki

Revision as of 06:33, 9 May 2011 by Henry (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax string.gsub( String base, String to replace (pattern), String replacement )
Where is this used?
Description:
Replaces old text with new specified text
Returns: String , Number Number of times found
Part of Library: String
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=String.gsub]String.gsub [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionReplace the chosen string with a new string
Used onNewerShared.png
Code
local oldString = "this is a test!"
 
local newString = string.gsub(oldString,"test","stickup")
 
Msg(newString)
Output"This is a stickup!"


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox