Clipboard Search & Replace v1.50
Search and replace text that is in your clipboard.
this is a Plugin to my personal script Mango. But I feel it was worthy of its own topic .
a simple script that mimics the basic windows Find and Replace dialogue, except this has a few more features.
There is a Preview button which allows you to see the changes before they are applied to the Clipboard.
Regex lets you find/replace using regular expression patterns.
<!-- m -->http://www.autohotke...ngo/Replace.ahk<!-- m -->
note: since this is a plugin for another one of my scripts, there is not hotkey to run/open the window. So you may want to add one.
keep typing frequently used search/replace combinations 8)
I have have my own buddy so I don't need it <!-- m -->http://www.autohotke...pic.php?t=42971<!-- m --> but could be a useful addition :wink:
For example in the following sentence 'her other coat was red'
When i find the word 'her' and replace it with his.
It results to: his othis coat was red.
When what i really wanted was - his other coat was red
Would this be possible to acheive??
sentence=her other coat is red
check character to the left of %var1% to be replaced and store the value into var_left
check character to the right of %var1% to be replaced and store the value into var_right
if both %var_left% and %var_right% contain spaces then replace %var1% with %var2%
else move on to next word in %sentence%
Unfortunatly i am no expert and can not offer a solution and also we need to think about speed if processing large text files. If anybody can offer a solution then this script would really come in handy for me.
Sentence=her other coat is red Sentence:=RegExReplace(sentence, "\bher\b", "his") MsgBox % Sentence
Also the spaces trick won't work if the word is followed by a comma, dot or is at the start or end of a string (there is no space in those cases before/after)
\b means "word boundary", which is like an anchor because it doesn't consume any characters. It requires the current character's status as a word character (\w) to be the opposite of the previous character's. It is typically used to avoid accidentally matching a word that appears inside some other word. For example, \bcat\b doesn't match catfish, but it matches cat regardless of what punctuation and whitespace surrounds it. Capital \B is the opposite: it requires that the current character not be at a word boundary.
if I replace StringReplace with a REGEX, then you cannot toggle the regex mode on/off. And having a constant Regex=on can be verry annoying.
I was playing around and had some issues besides that, soo, I'll keep thinking
soo, I'll keep thinking
Shame adding a checkbox is causing problems but at least in the meantime it will still work with 'whole word' replacment by inputting the \b \b directly into the 'Find what?' field around what you want it to find
when RegEx mode is selected.
Regular Expression are my nightmare
[*:32gnu3w2]Auto update of the preview display.
[*:32gnu3w2]Fixed some limitations when not in regex mode.
[*:32gnu3w2]Fixed the regex help sheet to be more accurate.
[*:32gnu3w2]Fixed drawing issues.
[*:32gnu3w2]Added support for tabs in both Find and Replace boxes.
[*:32gnu3w2]Added support for NewLines in the replace box.
regex I don't know about and may learn when and if needed; I want to concentrate on ahk.
As your script has both I may learn a bit of them if I'm able to grasp some of your code, which is not sure at all . . .
The search and replace also is actually what I try to do with a simple hotstring script.
Also I just started trying to make GUI follow my will . . .