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
Post a Comment