Difference between revisions of "Split"

From MyWiki
Jump to: navigation, search
Line 2: Line 2:
 
<br>
 
<br>
 
'''To get split to work properly to separate out a username with spaces :'''<br>
 
'''To get split to work properly to separate out a username with spaces :'''<br>
PS C:\scripts> $one = 'ab cd           ef'    <br>                                                                                                                                               
+
PS C:\scripts> $one = 'ab cd <serveral spaces>  ef'    <br>                                                                                                                                               
 
PS C:\scripts> $two = $one -Split('  ')      <br>                                                                                                                                           
 
PS C:\scripts> $two = $one -Split('  ')      <br>                                                                                                                                           
 
PS C:\scripts> $two[0]                        <br>
 
PS C:\scripts> $two[0]                        <br>

Revision as of 15:12, 27 August 2014

http://www.powershelladmin.com/wiki/Powershell_split_operator

To get split to work properly to separate out a username with spaces :
PS C:\scripts> $one = 'ab cd <serveral spaces> ef'
PS C:\scripts> $two = $one -Split(' ')
PS C:\scripts> $two[0]