multiple find and replace items

This forum is for all Flare related Tips and Tricks.
Have a tip or trick you use while working in Flare? Share it here.
Post Reply
bennetty
Propeller Head
Posts: 32
Joined: Tue Aug 19, 2014 8:28 am

multiple find and replace items

Post by bennetty »

Hi,
I have approx 30 find and replace items to perform in the source code of my topics. Is there a way to do this in one entire go or do I have to find and replace each of the 30 items individually. I know I can do this across the entire content folder but I want to enter all 30 items as well to in one go.

Any help would be much appreciated.

Thanks
Nicola.
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: multiple find and replace items

Post by NorthEast »

I'm assuming you mean there are 30 separate find/replace terms, rather than 30 occurrences of the same thing.

Anyway, the answer is 'maybe', as it depends on what exactly you're finding/replacing; is there a pattern that would allow you to use a wildcard or regular expression in the search?

If you don't know what these are, see: http://webhelp.madcapsoftware.com/flare ... eature.htm
bennetty
Propeller Head
Posts: 32
Joined: Tue Aug 19, 2014 8:28 am

Re: multiple find and replace items

Post by bennetty »

Hi Dave,
Just to confirm, the items I need to find always start and end with a @ but the content in between is different each time.

The replacement items always start with <span> and end with </span> but again the content in between is different depending on the above.

Thanks
kwag_myers
Propellus Maximus
Posts: 810
Joined: Wed Jul 25, 2012 11:36 am
Location: Ann Arbor, MI

Re: multiple find and replace items

Post by kwag_myers »

I know Dave will correct me if I'm wrong on this, but I believe that if you have 30 versions of replacing content, then each one must be done separately. If you Find "<span>*</span>" and Replace with "<span>All new content</span>" then every span will have the same "All new content" value.

Here's a script I use to replace unicodes with matching XML code. Use NotePad to edit the replace values (Replace(strText, "whatever old", "whatever new")). Then save the file with a VBS extension and double-click to run. A dialog opens for you to enter the folder directory.

Code: Select all

Const ForReading = 1
Const ForWriting = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")

objStartFolder = InputBox("Enter file directory ending with \","File Directory")

Set objFolder = objFSO.GetFolder(objStartFolder)

Set colFiles = objFolder.Files

For Each objFile In colfiles
fn = objFSO.GetFileName(objFile)
 
Set objFile = objFSO.OpenTextFile(objStartFolder & fn, ForReading)

strText = objFile.ReadAll
objFile.Close

strNewText = Replace(strText, "à", "à")
strNewText1 = Replace(strNewText, "á", "á")
strNewText2 = Replace(strNewText1, "â", "â")
strNewText3 = Replace(strNewText2, "ã", "ã")
strNewText4 = Replace(strNewText3, "ç", "ç")
strNewText5 = Replace(strNewText4, "è", "è")
strNewText6 = Replace(strNewText5, "é", "é")
strNewText7 = Replace(strNewText6, "ê", "ê")
strNewText8 = Replace(strNewText7, "ì", "ì")
strNewText9 = Replace(strNewText8, "í", "í")
strNewTextA = Replace(strNewText9, "î", "î")
strNewTextB = Replace(strNewTextA, "ñ", "ñ")
strNewTextC = Replace(strNewTextB, "ò", "ò")
strNewTextD = Replace(strNewTextC, "ó", "ó")
strNewTextE = Replace(strNewTextD, "ô", "ô")
strNewTextF = Replace(strNewTextE, "õ", "õ")
strNewTextG = Replace(strNewTextF, "ù", "ù")
strNewTextH = Replace(strNewTextG, "ú", "ú")
strNewTextI = Replace(strNewTextH, "û", "û")
strNewTextJ = Replace(strNewTextI, "Í", "Í")
strNewTextK = Replace(strNewTextJ, "º", "º")
strNewTextL = Replace(strNewTextK, " ", " ")
strNewTextM = Replace(strNewTextL, "ï", "ï")
strNewTextN = Replace(strNewTextM, "’", "’")
strNewTextO = Replace(strNewTextN, "À", "À")
strNewTextP = Replace(strNewTextO, "É", "É")
strNewTextQ = Replace(strNewTextP, "°", "°")
strNewTextR = Replace(strNewTextQ, "«", "«")
strNewTextS = Replace(strNewTextR, "»", "»")
strNewTextT = Replace(strNewTextS, "œ", "œ")

Set objFile = objFSO.OpenTextFile(objStartFolder & fn, ForWriting)
objFile.WriteLine strNewTextT
objFile.Close

Next

MsgBox "Ta Da! \0/" & strMsg, vbInformation, "Done!"
"I'm tryin' to think, but nothin' happens!" - Curly Joe Howard
Post Reply