AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to make case sensitive replacement?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
edu



Joined: 12 Oct 2006
Posts: 88
Location: Canada

PostPosted: Sat Oct 27, 2007 10:50 pm    Post subject: how to make case sensitive replacement? Reply with quote

Hello forum.
Let's say I have this variable:

textone = Green houses and green yards

and wanted to replace green with brown into a new variable, but in such a way that would preserve the word case:

textwo = Brown houses and brown yards

How can I achieve this?
_________________
The best things of life are free.
Back to top
View user's profile Send private message
hd0202



Joined: 13 Aug 2006
Posts: 58
Location: Germany

PostPosted: Sun Oct 28, 2007 9:09 am    Post subject: Re: how to make case sensitive replacement? Reply with quote

Code:

stringcasesense, on
stringreplace, texttwo, textone, green, brown, all
stringreplace, texttwo, texttwo, Green, Brown, all
stringcasesense, off


Hubert
Back to top
View user's profile Send private message
YMP



Joined: 23 Dec 2006
Posts: 266
Location: Russia

PostPosted: Sun Oct 28, 2007 9:33 am    Post subject: Reply with quote

Or use RegExReplace, which is case sensitive by default. It can also prevent replacing 'green' if it is part of some other word.
Code:

textone = Green houses and green yards
texttwo:=RegExReplace(textone, "/bgreen/b", "brown")
texttwo:=RegExReplace(texttwo, "/bGreen/b", "Brown")
MsgBox, % texttwo
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group