1 Jun 2010 22:34
Improved find/replace script
Hello (Sheri!) Some time ago Sheri, you helped me with a find and
replace script. This is one I made from your script to use on
highlighted text; this works, but I in my find-and-replace text file I
have to give the words both in sentence case as well as lowercase or it
won't find any words with the first letter capitalized. How can I make
this script know whether to apply sentence case, uppercase or lower case
to the words? Somehow it needs to know the case of the word it
imports. But this script uses vectors and a general replacement
function and I can't figure out how to get ahold of a single incoming
word in order to change or compare it. I just want to have lower-case
words in my find-replace list and then to fix the case as I replace the
words. I am sure this sounds rather confusing! Thank you!
Function ReplaceText(chgfile)
. <at> CapCB()
clip.copy ;;copy selection
wait.for(50)
local thestring = clip.get ;;get clipboard
local chgread=file.readall(chgfile)
local chgpat=regex.pcrecompile(?"(?m)^([^;][^=\r\n]*)=(.+)$")
local chgcount=chgpat.pcrematchcount(chgread)
if (chgcount==0) do
messagebox("no change records found, quitting")
quit
else
local chgVec=vec.create2D(chgcount, 3)
chgpat.pcrematchall(chgread,"",chgvec)
for (local i=0;i<chgcount;i++)
thestring = replacechars(thestring,chgVec[i,1],chgVec[i,2])
endfor
(Continue reading)
RSS Feed