PowerShell RegEx match all possible matches

Question:

I have the following script which includes some RegEx to capture specific information on this site.

This is matching the last ‘artist’. What I want to do is make this so it will run through and match every artist on this page in order top to bottom.

Answer:

PowerShell’s -match only returns first match. You have to use Select-String with -AllMatches parameter or [regex]::Matches.

Select-String:


[regex]::Matches:

Source:

PowerShell RegEx match all possible matches by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply