Reputation: 14596
I am looping through all files matching the pattern maint-*.js
.
These files contains tokens in the form of __MyTokenA__
, __MyTokenB__
, etc...so I would like to find all of these tokens. I've tried the regex below, but it doesn't find anything.
I'd like to store the tokens in an array. What would be the correct way ?
$files = Get-ChildItem dist/main-*.js
Foreach ($file in $files)
{
$matches = $file | Select-String ', "(?:\(__\))(.*?)(?:\(__\))"' -AllMatches
echo $matches
}
Upvotes: 0
Views: 808
Reputation: 12248
I think you can simplyfy your regex, then enumerate the matches property.
$file | Select-String '__(.*?)__' -AllMatches | ForEach-Object {
$_
$_.Matches | Select-Object Value
}
Upvotes: 1