AutoHotkey Community

It is currently May 26th, 2012, 11:43 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Remove double spaces
PostPosted: August 26th, 2005, 10:52 pm 
Offline

Joined: February 16th, 2005, 5:32 pm
Posts: 44
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 27th, 2005, 2:13 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 27th, 2005, 6:25 am 
Offline

Joined: February 16th, 2005, 5:32 pm
Posts: 44
Actually, that's about the same lines I had to replace multiple spaces. :wink: 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! :lol:


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, Pulover, rbrtryn, XstatyK, Yahoo [Bot] and 25 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group