Fox Rio
![]() |
No items matching your keywords were found.
Fox Rio

How to search a keyword from HTML file using Perl, or any other programming language?
Writing a program to find out whether the HTML file contain the word 'keyword' using Perl. Also please advise if other language is easier
Perl is pretty easy-- just as easy or easier than any other program out there to use, especially considering that many other languages use Perl's regular expression scheme, which is exactly what you want to be using. Here's pretty much what you want:
if($html =~ /bkeywordb/s) {
#yes! the keyword is there
} else {
#no! keyword is not there
}
That assumes that the whole HTML content is contained within the $html variable, of course-- and it also assumes a few other things, like that you don't want to match things like "blah_keywordfoo". But those are easy to change-- more detail could let us give you a more accurate answer, too.
[edit]Stripping out the html tags like that? Try this instead to strip out html tags:
s/?w+(s+w+|s+w+="[^"]*"|s+w+=[^ rnt>]+)*/?>//gs
Of course, Y!A won't let me post that code in full, so here it is broken down on several lines (annoying):
s/?w+(s+w+|s+
w+="[^"]*"|s+w+=[
^ rnt>]+)*/?>//gs
That ought to take care of all your HTML tags, and nothing else, with the arguable exception of HTML tags in JavaScript text strings.
[/edit]
DaveE
Angry Birds Rio Trailer

Leave a Comment