List Info

Thread: Simple regex newbie query




Simple regex newbie query
user name
2006-03-01 20:33:50
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 regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )