Untitled
unknown
plain_text
2 years ago
637 B
6
Indexable
# Read the content of the file
$fileContent = Get-Content -Path "your_file_path.txt" -Raw
# Find matches using regex
$matches = [regex]::Matches($fileContent, '>([0-9]+)<')
# Count the occurrences of each matched number
$matchCount = @{}
foreach ($match in $matches) {
$number = $match.Groups[1].Value
if ($matchCount.ContainsKey($number)) {
$matchCount[$number]++
} else {
$matchCount[$number] = 1
}
}
# Display the results
foreach ($entry in $matchCount.GetEnumerator() | Sort-Object -Property Value -Descending) {
Write-Output "$($entry.Key): $($entry.Value) occurrences"
}
Editor is loading...
Leave a Comment