aemain has asked for the wisdom of the Perl Monks concerning the following question:
Hey Monks,
I've spent a fair amount of time doing somewhat basic regular expressions, but this one really has me stumped. I'm writing an web encyclopedia feature, such that the first occurrence of a given word is turned into a hyperlink to the encyclopedia entry. The problem is that the text being replaced may already have hyperlinks in it, and that some encyclopedia terms include other terms. For example, simplistic regular expressions fail when asked to add links to Globalization on this text:
Oh no, <a href="/encyclopedia/Anti-Globalization/index.html">Anti-glob +alization</a> activists are coming! Globalization is rejected by...
In this case, we would obviously want the script to ignore the url and the linked text, and instead place the new link in the last sentence.
Thanks so much
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Searching for text not inside a hyperlink
by valdez (Monsignor) on Jun 06, 2004 at 19:54 UTC | |
|
Re: Searching for text not inside a hyperlink
by Zaxo (Archbishop) on Jun 06, 2004 at 18:35 UTC | |
|
Re: Searching for text not inside a hyperlink
by bart (Canon) on Jun 07, 2004 at 07:33 UTC |