by stocksp at 2013-02-13 21:09:23
"1b4c6f8" -match ("\d")by vstarmanv at 2013-02-13 21:27:58
I expected 4 matches (as I do get in ‘regular’ .net) but $matches only returns one.
What is the syntax for multiple matches?
thanks!
P:)
do you want this?by stocksp at 2013-02-13 23:05:14
([char]"1b4c6f8" -match "\d").Count
No, I need the values. My actual expression is more complex. I’m scrapping an HTML document.by Klaas at 2013-02-14 01:04:39
I want a collection of all the matches.
The simple example should produce a collection with 4 numbers
I found this tip from Keith Hill. It’s from 2007 so there may be another way by now, but this works.by mjolinor at 2013-02-14 03:38:22([regex]'\d').matches("a1b2c3d4e5") | Foreach { $.value }
http://rkeithhill.wordpress.com/2007/09/29/effective-powershell-item-9-regular-expressions-one-of-the-power-tools-in-powershell/
That first solution posted should work, if you just get rid of the ().count:by stocksp at 2013-02-14 08:56:15[char[]]"1b4c6f8" -match "\d"
Thanks a million!by Klaas at 2013-02-14 09:11:10
I have a ‘page’ of text and I’m looking for a list of ‘WINNER OF THE XXX…’ embedded in HTML
Smatches[0] contains the page.
([regex]‘(WINNER OF.*(?=</div>))’).matches($matches[0]) | Foreach { $.value }
This works perfect. Is there a solution that uses -match?
P:)
I don’t think so.
This is a part of the about_comparison_operators:
[quote] -Match
Description: Matches a string using regular expressions.
When the input is scalar, it populates the
$Matches automatic variable.
Example:
PS C:> "Sunday" -Match "sun"
True
PS C:> $matches
Name Value
---- -----
0 Sun
PS C:> "Sunday", "Monday" -Match "sun"
Sunday[/quote]