Powershell - Using String Functions


Source: http://powershell.com/cs/blogs/tips/archive/2009/06/08/using-string-functions.aspx

PowerShell uses .NET objects everywhere. Anything is represented as .NET object, and .NET objects come with useful built-in methods. However, for string manipulation you do not need to look for sophisticated external commands as they are built right into strings.

Here are a couple of useful examples:

"Hello".Insert(3, "INSERTED")
"Hello".Replace('l', 'x')
" remove space at ends ".Trim()
" remove space at ends ".Trim(' rem')

No comments:

Post a Comment