Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
637 B
2
Indexable
Never
# 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"
}
Leave a Comment