Skip to main content

Javascript regex replace weird behavior



I'm developing a js to dig up Bible references on Portuguese web pages, and link them to a youversion.com url.





This is one of those pages: http://www.adventistas.org.pt/Evangelismo/Web/Img/Downloads/Trimensario/2012/1t/online/licao7.htm





This is the script: http://www.adventistas.org.pt/Evangelismo/Web/Img/Downloads/Trimensario/2012/1t/online/bibleref.js





It pretty much works, but it acts kinda funny, and can't find out why.





Sometimes it outputs empty links with correct bible references, and then outputs the real link, with a wrong reference.





Eg:







<a target="_blank" href="http://www.youversion.com/bible/verse/arc/gen/2/1-3" class="passagem"></a>

<a target="_blank" href="http://www.youversion.com/bible/verse/arc/gen/2/1-3" class="passagem"></a>

<a target="_blank" href="http://www.youversion.com/bible/verse/arc/gen/2/1-3" class="passagem"></a>

<a target="_blank" href="http://www.youversion.com/bible/verse/arc/gen/2/1-3" class="passagem"></a>

<a target="_blank" href="http://www.youversion.com/bible/verse/arc/gen/2/1" class="passagem">Génesis 2:1</a>-3;







Sometimes it works perfectly. Can anyone help track down the culprit?





Thanks!


Comments

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?