regex - Spiting Regular expression and accessing Array of Array -
an example trying understand website. people2.txt follows.
2323:doe john california
827:doe jane texas
982982:neuman alfred nebraska
i don't output shown command below.
*ps c:\ get-content people2.txt | %{$data = [regex]::split($_, '\t|:'); write-output "$($data[2]) $($data[1]), $($data[3])"}
john doe, california
jane doe, texas
alfred neuman, nebraska*
i take out numbers , swapping first , second using
gc c:\appl\ppl.txt | %{$data = [regex]::split($_, ":") ;write-output $data[1] } | out-file c:\appl\ppll.txt
gc c:\appl\ppll.txt | %{$data = $_.split(" "); write-output "$($data[1]) $($data[0]), $($data[2])"}
please help
**need find more efficient ways this.
also want understand '\t|:' - 'split @ first tab stop , : ' ?**
just threw off top of head: ^(?<number>\d+):(?<first>\w+)\s+(?<last>\w+)\s(?<location>.*)$
Comments
Post a Comment