Trying to match a blank column in CSV with regex

Hello Everyone,

 

I am trying to match a blank column with regex in CSV and using below code but not returning anything for me. I can find blank column via where object but want to strictly use regex here for matching.

 
<p class=“p1”>Import-CSV -Path “C:\Servicess.CSV” | Where-Object {$_.Site -Match “\s+”} </p>
 

Thanks

 

 

\s+ matches 1 or more whitespace characters but you have an empty cell, not a cell with whitespace characters. Try using ^$ to match an empty string.

That Worked, Thanks alot.

Another way without regex:

Import-CSV -Path “C:\Servicess.CSV” | Where-Object {[string]::IsNullOrEmpty($_.Site)} 

Thanks alot.