New topic: RegEx and Replacement
<http://forums.realsoftware.com/viewtopic.php?t=47070> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message dscl Post subject: RegEx and ReplacementPosted: Mon Feb 25, 2013 4:54 pm Joined: Fri Apr 30, 2010 11:02 am Posts: 25 Hello everyone here we go with yet another RegEx question. What I am trying to do is read in an HTML file and find URLs. Those URLs need to be modified and that's it. What's happening though is because the replacement URL actually matches the regex pattern I get caught in a loop. What I need to do is go through the document top down and not pick up a URL more than once. Here's the basic code // setup RegEx Dim hrefReg As RegEx hrefReg = New RegEx hrefReg.Options.CaseSensitive = False hrefReg.SearchPattern = "<a([^"">]*)href=""([^"">]*)""([^>]*)>" Dim hrefMatch as RegExMatch // find the match hrefMatch = hrefReg.Search(theData) if hrefMatch <> Nil then while hrefMatch <> Nil hrefReg.ReplacementPattern = "<a" +hrefMatch.SubExpressionString(1) +"href=""\$clickthrough(" + Listbox1.Cell(i,0) + tExtras + ")\$""" + hrefMatch.SubExpressionString(3) +">" theData = hrefReg.Replace(theData) // Prepare next match i = i + 1 hrefMatch = hrefReg.Search() wend end Any thoughts/ideas? Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
