I am using regex in php to parse an RSS feed looking for
certain
keywords. The script works well except that when I am trying
to get a
positive on the word "train" (which works) I
also get a false positive
on the word "training" - but only if it is at
the start of an RSS item.
$keywords = array("rail", "railway",
"railways", "train",
"trains",
"level crossing", "tube",
"bond underground", "railtrack",
"eurostar");
# create regular expression in format
"^rail|[[:space:]]rail[[:space:]]|rail$"
# this means any line beginning with rail OR any line with
rail with
space either side OR any line ending with rail - or does it?
$keyString = "^" . $keywords[$counter] .
"|[[:space:]]" .
$keywords[$counter] . "[[:space:]]|" .
$keywords[$counter] . "$";
if(eregi($keyString, $title) || eregi($keyString,
$description)) {
# do stuff
Thanks in advance
Gaz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|