 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
edu
Joined: 12 Oct 2006 Posts: 88 Location: Canada
|
Posted: Sat Oct 27, 2007 10:50 pm Post subject: how to make case sensitive replacement? |
|
|
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 |
|
 |
hd0202
Joined: 13 Aug 2006 Posts: 58 Location: Germany
|
Posted: Sun Oct 28, 2007 9:09 am Post subject: Re: how to make case sensitive replacement? |
|
|
| Code: |
stringcasesense, on
stringreplace, texttwo, textone, green, brown, all
stringreplace, texttwo, texttwo, Green, Brown, all
stringcasesense, off
|
Hubert |
|
| Back to top |
|
 |
YMP
Joined: 23 Dec 2006 Posts: 266 Location: Russia
|
Posted: Sun Oct 28, 2007 9:33 am Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|