String trimming
hi,
can me simple task....
i have powershell script returns series of strings variables such as:
sql-instance1-<some more text>
sql-instance2-<some more text>
sql-instance3-<some more text>
i want pass of string to, not including last hyphen new variable, trim off <some more text> part, so for example the value of variables 'sql-instance1', 'sql-instance2' , 'sql-instance3'
i have used lastindex of return values after last hyphen struggling returning values last hyphen.
can help?
thanks
$str = 'sql-instance3-qwerty' $str.substring(0,$str.lastindexof("-"))
karl
blog: http://unlockpowershell.wordpress.com
book: windows powershell 2.0 bible
e-mail: -join ("6b61726c6d69747363686b65406d742e6e6574"-split"(?<=\g.{2})",19|%{[char][int]"0x$_"})
Windows Server > Windows PowerShell
Comments
Post a Comment