DTW-DanWard / PowerShell-Beautifier

A whitespace reformatter and code cleaner for Windows PowerShell and PowerShell Core
MIT License
333 stars 38 forks source link

Removed ` character from if statement with Regex #66

Open beancurd1 opened 2 years ago

beancurd1 commented 2 years ago

Thanks for making this great script, this is the only beautifier I could find online so far. I installed PowerShell-Beautifier yesterday. I found a small issue when running your it, it converted most of my scripts fine except the following samples. It removed ` character from the if statement. I did a BeyondCompare to find that out. You can use the following sample to reproduce the issue. Thanks for looking into it. Interesting, I just noticed I need to use \ to escape ` in the sample below, otherwise it won't show on github ~~~ so both github and PowerShell-Beautifier seemed to ignore it :)

SAMPLE

if ($line -match "[0-3]?\d[\/| |-][ADFJMNOS]\w{2,9}[\/| |-]\d{2,4}" -or ` # break the loop if an incorrect date ' MMM yyyy', ' MMMM yyyy', '-MMM-yy' format are found. $line -match "[0-3]?\d\/\d?\d\/\d{2,4}" ) { ` # OR break the loop if an incorrect date format dd/mm/yyyy is found. write-host "test" }