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.
Download:
<!-- m -->https://ahknet.autoh...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.
rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .
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??
rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .
Example:
sentence=her other coat is red
var1=her
var2=his
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
rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .
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.
\bher\b
Regular Expression are my nightmare
Added Whole Word Only mode.
rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .
This handy script and your time spent adding the whole word replace feature are very much appreciated indeed.
New version, 1.40.
Added a regex quick reference.
Made the GUI resizable.
rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .
[*: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]Code optimization.
[*:32gnu3w2]Added support for tabs in both Find and Replace boxes.
[*:32gnu3w2]Added support for NewLines in the replace box.
rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .
I may learn a bit reading your script.
Good work.
what are you going to try and learn from it? regex? or just the concept? or other?
rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .
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 . . .
:roll: