Trim()

Auto Hotkey

Trim

Trims characters from the beginning and/or end of a string.

OutputVar := Trim(String, OmitChars)
OutputVar := LTrim(String, OmitChars)
OutputVar := RTrim(String, OmitChars)
Function Example: result := Trim(text,"`n`r")

Parameters

OutputVar

The name of the variable in which to store the new string.

String

Any string value or variable. Numbers are not supported.

OmitChars

An optional list of characters (case sensitive) to exclude from the beginning and/or end of String. If omitted, spaces and tabs will be removed.

Examples

text := "  text  "
MsgBox % "No trim:`t '" text "'"
    . "`nTrim:`t '" Trim(text) "'"
    . "`nLTrim:`t '" LTrim(text) "'"
    . "`nRTrim:`t '" RTrim(text) "'"
MsgBox % LTrim("00000123","0")