 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
delta
Joined: 16 Feb 2005 Posts: 44
|
Posted: Fri Aug 26, 2005 9:52 pm Post subject: Remove double spaces |
|
|
I have a string in which I want to contract double spaces to single spaces.
I was trying this:
| Code: | | StringReplace, word, word, %A_Space%%A_Space%, %A_Space%, All |
No success. So I tried
| Code: | AutoTrim, Off
StringReplace, word, word, %A_Space%%A_Space%, %A_Space%, All |
Still the same.
I tried
| Code: | AutoTrim, Off
ds := " "
s := " "
StringReplace, word, word, %ds%, %s%, All |
and still no success.
Then I tried
| Code: | | StringReplace, word, word, aa, a, All |
and it worked right away. So what's wrong with those spaces? How do I have to do it? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Sat Aug 27, 2005 1:13 am Post subject: |
|
|
Most of those examples should work okay. For example, I tested the following and it produces the right answer:
| Code: | word = 12 34 56
StringReplace, word, word, %A_Space%%A_Space%, %A_Space%, All |
However, the above will not work completely if you have any triple-spaces, quad-spaces, etc. In that case, you could try the following:
| Code: | Loop
{
StringReplace, word, word, %A_Space%%A_Space%, %A_Space%, UseErrorLevel
if ErrorLevel = 0 ; No more replacements needed.
break
} |
|
|
| Back to top |
|
 |
delta
Joined: 16 Feb 2005 Posts: 44
|
Posted: Sat Aug 27, 2005 5:25 am Post subject: |
|
|
Actually, that's about the same lines I had to replace multiple spaces. Seeing you using those as well I concluded that the error must be elsewhere. A hex viewer finally revealed that there were no multiple spaces but multiple tabs! But they sure looked like spaces!  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|