Trim

Removes leading and trailing whitespace characters from a string.

Syntax

Trim(text)

Parameters

  • text (string): The string to trim

Returns

  • string: The input string with leading and trailing whitespace removed

Description

Removes spaces, tabs, carriage returns, line feeds, and other Unicode whitespace characters as defined by the .NET framework. Preserves internal whitespace.

Examples

var result1 = Trim("  hello world  ")    # Returns "hello world"
var result2 = Trim("\t\ntest\r\n")       # Returns "test"
var result3 = Trim("no spaces")          # Returns "no spaces"
var result4 = Trim("  space inside  ")   # Returns "space inside"

Back to top

Copyright © Mesch Systems. All rights reserved.