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.

multiple find and replace items

Postby bennetty on Tue Oct 07, 2014 6:02 am

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.

Propeller Head
Posts: 32
Joined: Tue Aug 19, 2014 8:28 am

Re: multiple find and replace items

Postby Dave Lee on Tue Oct 07, 2014 6:10 am

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: ... eature.htm
Dave Lee
Master Propellus Maximus
Posts: 5560
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: multiple find and replace items

Postby bennetty on Mon Oct 13, 2014 2:38 am

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.

Propeller Head
Posts: 32
Joined: Tue Aug 19, 2014 8:28 am

Re: multiple find and replace items

Postby kwag_myers on Tue Oct 14, 2014 7:01 am

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

strNewText = Replace(strText, "&agrave;", "&#224;")
strNewText1 = Replace(strNewText, "&aacute;", "&#225;")
strNewText2 = Replace(strNewText1, "&acirc;", "&#226;")
strNewText3 = Replace(strNewText2, "&atilde;", "&#227;")
strNewText4 = Replace(strNewText3, "&ccedil;", "&#231;")
strNewText5 = Replace(strNewText4, "&egrave;", "&#232;")
strNewText6 = Replace(strNewText5, "&eacute;", "&#233;")
strNewText7 = Replace(strNewText6, "&ecirc;", "&#234;")
strNewText8 = Replace(strNewText7, "&igrave;", "&#236;")
strNewText9 = Replace(strNewText8, "&iacute;", "&#237;")
strNewTextA = Replace(strNewText9, "&icirc;", "&#238;")
strNewTextB = Replace(strNewTextA, "&ntilde;", "&#241;")
strNewTextC = Replace(strNewTextB, "&ograve;", "&#242;")
strNewTextD = Replace(strNewTextC, "&oacute;", "&#243;")
strNewTextE = Replace(strNewTextD, "&ocirc;", "&#244;")
strNewTextF = Replace(strNewTextE, "&otilde;", "&#245;")
strNewTextG = Replace(strNewTextF, "&ugrave;", "&#249;")
strNewTextH = Replace(strNewTextG, "&uacute;", "&#250;")
strNewTextI = Replace(strNewTextH, "&ucirc;", "&#251;")
strNewTextJ = Replace(strNewTextI, "&Iacute;", "&#205;")
strNewTextK = Replace(strNewTextJ, "&ordm;", "&#186;")
strNewTextL = Replace(strNewTextK, "&nbsp;", "&#160;")
strNewTextM = Replace(strNewTextL, "&iuml;", "&#239;")
strNewTextN = Replace(strNewTextM, "&rsquo;", "&#8217;")
strNewTextO = Replace(strNewTextN, "&Agrave;", "&#192;")
strNewTextP = Replace(strNewTextO, "&Eacute;", "&#201;")
strNewTextQ = Replace(strNewTextP, "&deg;", "&#176;")
strNewTextR = Replace(strNewTextQ, "&laquo;", "&#171;")
strNewTextS = Replace(strNewTextR, "&raquo;", "&#187;")
strNewTextT = Replace(strNewTextS, "&oelig;", "&#339;")

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


MsgBox "Ta Da! \0/" & strMsg, vbInformation, "Done!"
"I'm tryin' to think, but nothin' happens!" - Curly Joe Howard
Propellus Maximus
Posts: 808
Joined: Wed Jul 25, 2012 11:36 am
Location: Ann Arbor, MI

Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 1 guest