Found this while debugging a Powershell script.
PS C:\temp> "hello" -match $null
True
But
> "hello" -eq $null returns False
Why, when using -match, any string will match with $null?
I believe this is because the $null gets coerced to an empty string as -match expects a string pattern on the RHS (Right Hand Side). And an empty string will match anything.
"hello" -match [NullString]::Value explodes with an ArgumentNullException.
$nullregular expression matches anything because it matches against nothing. Similarly you can insert as many${null}s as you want into the middle of a pattern and not affect its matching because they simply expand to nothing.