Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Regular Expressions

$
0
0

I have this code:

$text='Regular Expressions in PowerShell: KB987654, KB987111, KB987999, KB987222 Get all KB numbers.'
$pattern='KB(\d{4,6})'
$text-match$pattern
$matches

when I run this it returns the following.

Name Value
---------
1 987654
0 KB987654

 

It only returns the First KB number and it returns it twice.  How do I make this return all 4 KB numbers?

Thanks.  


Viewing all articles
Browse latest Browse all 6937

Trending Articles