in reply to matching any string except a regex
This is probably on the borderline of what should be attempted with just regexen. The approach I'd take would be:
- Use HTML::TreeBuilder to handle parsing the HTML
- look_down the tree for p elements
- Get the text contents of each of those elements and tokenize it on whitespace (i.e. using split)
- Walk over the list of tokens, ignoring simple text, remembering the last mentioned book for wikirefs, and replacing textual references with the corresponding wikirefs
- join the resulting items back together and replace the element contents
When the regex going gets tough, the tough get writing simple parsers and it's not so tough any more.
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
---|
In Section
Seekers of Perl Wisdom