Powershell - Using String Functions

2010/12/23 | less than 1 minute read |

<p></p> <p>Source: http://powershell.com/cs/blogs/tips/archive/2009/06/08/using-string-functions.aspx</p> <p>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.</p> <p>Here are a couple of useful examples:</p><div style="padding-bottom: 0pt; margin: 10px 20px; padding-left: 0pt; padding-right: 0pt; font-family: ; white-space: pre; padding-top: 0pt" class="pscode">"Hello".ToLower()
"Hello".Insert(3, "INSERTED")
"Hello".Replace('l', 'x')
" remove space at ends ".Trim()
" remove space at ends ".Trim(' rem')</font></font>

Leave a comment