string.Trim

From GMod Wiki

Revision as of 21:11, 3 August 2010 by KnowledgeJunkie (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax string.Trim( String string, [ String char ] )
Where is this used?
Description:
Removes leading and ending white spaces from a string.
Returns: String
Part of Library: String
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=String.Trim]String.Trim [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionRemove whitespace from the front (head) and back (tail) of the given string.
Used onNewerShared.png
Code
local my_string = "     This is a string which has many white spaces at the beginning and the end      "
print(string.Trim(my_string))
Output"This is a string which has many white spaces at the beginning and the end" (Notice the heading and trailing white space has been removed)


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox