0

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
 }

1 Answer 1

1

I think you can simplyfy your regex, then enumerate the matches property.

$file | Select-String '__(.*?)__' -AllMatches | ForEach-Object {
    $_
    $_.Matches | Select-Object Value
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.