The solutions that have been proposed so far give only the first match on each line. To fully emulate the grep -o behavior (which produces every match from each line), the following is required:
Get-Content filename | Select-String '>([0-9])' -AllMatches | Select-Object -Expand Matches | % { $_.Groups[1].Value }
Select-String -AllMatches returns all matches from the input string.
Select-Object -Expand Matches "disconnects" matches from the same row, so that all submatrices can be selected using $_.Groups[1] . Without this extension, the feed from the second string match will be $_.Groups[3] .
source share