# Set the path to the file you want to check
$file = "C:\Users\a.warme\Documents\nps_cleanup\apworkfile2.txt"

# Define a regular expression to search for common mistakes
$regex = '\s+$|(?<!\s)\+|(?<!\s)-|(?<!\s)\*|(?<!\s)/|(?<!\s)\%'

# Read the file contents and search for the regular expression
$content = Get-Content $file -Raw
$matches = [regex]::Matches($content, $regex)

# Loop through the matches and output the line number and content of the line
foreach ($match in $matches) {
    $line = $content.Substring(0, $match.Index).Split("`n").Count
    if ($line -le ($content.Split("`n").Count)) {
        $lineContent = $content.Split("`n")[$line - 1]
        Write-Host "Potential mistake on line ${line}:`n${lineContent}`n"
    }
}
