View Single Post
Old 07-23-2008   #2 (permalink)
Shay Levy [MVP]


 
 

Re: find all href attributes

Hi rshillington,

Try this, the regex pattern may vary:


dir *.as?x | foreach{
$regex = '<a\s+[^>]+?href="(?<href>[^"]+)"'
$content = cat $_
[regex]::Matches($content,$regex) | foreach { $_.Groups["href"].Value }
}




---
Shay Levy
Windows PowerShell MVP
blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic



r> I want to search all .as?x files for href attributes and produce a
r> sorted distinct list of the attribute values. I'm pretty sure this
r> is easily doable with PowerShell. Any pointers would be greatly
r> appreciated.
r>


My System SpecsSystem Spec