lundi 10 novembre 2008

Windows PowerShell and regex?

Yesterday, I was researching PowerShell for work and I was quite impressed, it is pretty powerful! I obviously cannot stand the hype and self-satisfied twits making over-enthusiastic remarks in the Windows PowerShell Owner’s Manual like:

To impress your colleagues, show them "dot source", if they are not impressed, nothing will impress them ...

"dot source", lol, that has been around for decades ;-), even on Windows with Microsoft's own ksh (i.e. in the Unix Services 4 Windows) ...

What does impress me in PowerShell, is the wmi integration, that is really cool! Also, the PowerShell is very good in interacting with .Net objects, as it can pass objects between different 'cmdlets' instead of strings, unlike most shells.

Regex is there as well, well, actually, sort of ....

Because, when the twits over at Redmond implement a standard, why, YES, WHY can't they stick to the standard? Look at regex for powershell, it is not case sensitive by default, not greedy and worse of all, '?' and '*' have all of a sudden become '.?' and '.*', respectively! How can they call that regex? There are certainly other things I have overlooked .... I would call the implementation Glogex or RegGlobex - they merged GLOB with regular expressions ...

The regex implementation in vbs is much better, as it has not been merged with GLOB!

I often use this regex cheat sheet, compare that to what is said here.