Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Regex SOS – Splitting Elements from a Variable With Regex?

$
0
0

Hi All,

Scenario:

I’ve got a variable with a bunch of computer names in it. All our machines are named starting with two letters that signify their geographic location. I’d like to be able to split these into other variables as needed for just the machines starting with those letters.

$Computer = "@ AA-Computer-1 AA-Computer-2 BB-Computer-1 BB-Computer-2 CC-Computer-1 CC-Computer-2 @" -split 'r+' 

What do I put here to filter out the AA-XXXXX computers? I don’t necessarily need to store them into another variable, just being able to get those out into the console on demand would be plenty.

submitted by /u/NtGuru
[link] [comments]

The post Regex SOS – Splitting Elements from a Variable With Regex? appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles