![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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 | Re: loop through text and create array $arr = $tmp = @() switch -r -file .\data.txt { '^-{2,}' {if ($tmp) {$arr += ,$tmp; $tmp = @()}} default {$tmp += $_} } $arr.count $arr[1] -- Kiron |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: loop through text and create array >1) '^-{2,}' - "start's with 2 or more -"
2) By precedind $tmp with the Comma Operator the array is being appended to $arr as an array. Without the Comma Operator $tmp's items would be assigned individually. # empty arrayS $ar0 = $ar1 = @() # w/ comma operator $ar0 += ,(0..3) $ar0 += ,(2..7) $ar0 += ,(9..1) $ar0.count $ar0[1] # w/o comma operator $ar1 += 0..3 $ar1 += 2..7 $ar1 += 9..1 $ar1.count $ar1[1] -- Kiron | ||||||||||||
My System Specs![]() | |||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Overwrite Text File in Loop | MacMan0295 | VB Script | 3 | 08-18-2008 04:35 PM |
| How to create a hash table from an array | RickB | PowerShell | 2 | 08-08-2008 04:51 PM |
| Create a multiline array...how? | greatbarrier86 | VB Script | 5 | 05-28-2008 11:51 AM |
| loop through and array | Joe N | PowerShell | 8 | 07-09-2007 12:06 AM |
| how to assign values to array and how to create array via variable | Frank | PowerShell | 1 | 03-13-2007 05:18 PM |