![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | remove spaces from end of string Hi, What is the best way to remove spaces from the end of a string, ie. $string = "abcdef 123 " I want to trim the string to be "abcdef 123" thanks, |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: remove spaces from end of string "Frank" <Frank@discussions.microsoft.com> wrote in message news:1E13887D-C790-4746-9810-642F97F01F88@microsoft.com... > Hi, > > What is the best way to remove spaces from the end of a string, ie. > > $string = "abcdef 123 " > > I want to trim the string to be "abcdef 123" $string = "abcdef 123 ".TrimEnd() -- Keith |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: remove spaces from end of string On Jun 13, 1:17 am, "Keith Hill [MVP]" <r_keith_h...@mailhot.nospamIdotcom> wrote: > > I want to trim the string to be "abcdef 123" > > $string = "abcdef 123 ".TrimEnd() Another related technique which I found useful: # "abcdef 123 ".Split(" ", [StringSplitOptions]::RemoveEmptyEntries) abcdef 123 This tip came via Bruce Payette's "Powershell in Action" book. Portion available online: http://www.microsoft.com/technet/scr...ette1.mspx#EKC |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remove Newline from String | Kurt | PowerShell | 1 | 07-08-2008 12:07 PM |
| VBScript run generates errors with blank spaces in the string to beexecuted | newbie123 | VB Script | 2 | 05-22-2008 08:35 AM |
| problems with $var | select-string -pattern $string -q | Ben Christian | PowerShell | 3 | 02-08-2008 12:41 PM |
| String PRODUCT_NAME was not found in string table | Extracampine | Vista General | 3 | 02-12-2007 06:15 AM |
| Why does get-content on a text file remove crlf when cast to a string? | Mark | PowerShell | 7 | 09-22-2006 11:50 AM |