Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dealing with arrays

3 views
Skip to first unread message

brady maxwell

unread,
Jun 16, 2009, 1:14:28 PM6/16/09
to
So I have an array with three values for each record. I want to write to the
screen all the records where one of the vaules match a string.

Anyone have a sample of something like that?


Thanks

Marco Shaw [MVP]

unread,
Jun 20, 2009, 4:27:08 PM6/20/09
to
So do you mean you have something like this:

PS>$arr=@(@("a","b","c"),@("d","e","f"))

What exactly do you want to do once you do find a match?

Here's an example:
PS>$arr|foreach{$_|foreach{$_ -match "c"}}

Or perhaps, you have:

PS>$arr=@("foo;bar;abc","def;ghi;jkl")

In the later part, you have 2 elements, but want to *split* out each part
into...

PS>$arr|foreach{$_.split(";")}

"brady maxwell" <maxwe...@osu.edu> wrote in message
news:C65D4B34.632C%maxwe...@osu.edu...

Robert Fergus

unread,
Aug 4, 2009, 3:21:01 PM8/4/09
to
Brady,

Here are some ideas I can offer.

Here is another way of using Powershell (with the help of DotNet) to do this
for you.

### First I create an array using Ipconfig and display the information###

$Ipconfig = C:\Windows\System32\ipconfig.exe -all
$Ipconfig

### Next I use Dotnet Regex and Foreach-Object ###
$IpconfigInfo =
[regex]::Matches($Ipconfig,'(\w\w-\w\w-\w\w-\w\w-\w\w-\w\w)')|ForEach-Object
-Process {$_.Groups}

### then to display the information ###
$ipconfigInfo|ForEach-Object -Process {$_.Value}
# OR
$ipconfigInfo.SyncRoot[0].value
#OR
$ipconfigInfo.SyncRoot[2].value

## Try it out ##

0 new messages