![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Remove Blank spaces from a Doc I am trying to format a file that has many blank space in between words, so I am trying to replace them with a ":" This is my code, and it is not working: Get-Content ".\list.log" | ForEach-Object {$_ -replace '\s+(?!$)', ',' } | Set-Content .\new-list.log" Any help is appreciated. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Remove Blank spaces from a Doc Thanks it did help, in some way, I used (gc list.log) -replace '\s{2,}',':', but it replaced all blank spaces with ":" so I get: Server:::::::::::::::System::::::::: and I am looking for: Server:System. I am learning how to write scripts, Thanks! "Kiron" wrote: Quote: > Try this: > > # to replace two or more with a ':' > (gc list.log) -replace '\s{2,}',':' > > # to replace one or more > (gc list.log) -replace '\s+',':' > > -- > Kiron > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Remove Blank spaces from a Doc This is the text that I have: dapp203ntv MIC CRS Index erver uproxy01lxv UAT F5 LB reverse proxy uproxy02lxv UAT F5 LB reverse proxy And this what I get" dservera::::::::::::::::::::::::MIC CRS Index erver pservera::::::::::::::::::::::::UAT F5 LB reverse proxy qservera::::::::::::::::::::::::UAT F5 LB reverse proxy Uservera::::::::::::::::::::::::Index server This is what would like to see dservera:MIC CRS Index erver pservera:UAT F5 LB reverse proxy qservera:UAT F5 LB reverse proxy Uservera:Index server "Kiron" wrote: Quote: > 'System Server ' -replace '\s{2,}',':' > > The multiple ':' in the result you're getting is odd, there should be one > ':' for any continuous whitespace between words. The ':' after the last > word -or before the first- can be taken care of with a consecutive > replacements: > > Try this: > > ' System Server ' -replace '^\s+|\s+$' -replace '\s+',':' > ' System Server ' -replace '^\s+|\s+$' -replace '\s{2,}',':' > > If multiple ':' are still output, and you _can_ share the first line of > your list.log, post the output of either: > "$([int[]][char[]](gc list.log -t 1))" > # or... > "$(gc list.log -t (gc list.log -t 1).length -en byte)" > > -- > Kiron > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Remove Blank spaces from a Doc Quote: > dapp203ntv MIC CRS Index erver > uproxy01lxv UAT F5 LB reverse proxy LogParser.exe "SELECT Field1 AS [The First Field], Field2 as TheSecondField FROM aTest123.txt " ` -i tsv -iSeparator spaces ` -headerRow off -nFields 2 ` -o tsv -oSeparator ":" ` -headers off -q on Returns: dapp203ntv:MIC CRS Index erver uproxy01lxv:UAT F5 LB reverse proxy uproxy02lxv:UAT F5 LB reverse proxy Uservera:Index server Just ask any _automation_ tool, powershell.exe, user for more information, about automating the data parsing tool, logparser.exe! |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Uninstalled applications left permanent blank spaces in start menu | Vista General | |||
| How to remove blank space at end of movie project | Vista music pictures video | |||
| VBScript run generates errors with blank spaces in the string to beexecuted | VB Script | |||
| blank spaces in display | Vista performance & maintenance | |||
| remove spaces from end of string | PowerShell | |||