Searching for three spaces in a line


i trying find 3 spaces in line contains multiple spaces, once found  replace comma e.g.

before:

aaa   bbb   ccc   ddd    eee   fff

after:

aaa,bbb,ccc,ddd    eee   fff

the regex query i have used so far finds spaces , tabs "\s{3,}|\t+". want return first three. has done before using regex queries?

here's own question answered, maybe bring clarity original question asking

$string = "aaaa              bbbbccc     c   dddd    eeee    ffff   gggg"
[regex]$pattern = "\s+"
$pattern.replace($string, ",", 3)  

output:

aaaa,bbbbccc,c,dddd    eeee    ffff   gggg



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

difference between wuauclt1.exe and wuauclt.exe

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL