i am designing a search engine for our website. i want to allow for
searchablity based on partial string match as well as quoted exact
matches. for example the search
search text many
would return a result if there are any part of our site that has both
words in it in any order -> ex. a page containing the string "a search
of textbooks gives many results"
however if the search was
"search text" many
then the previous result would not return since the words do not
appear exactly in the order of the quotes string. however, a page with
the string "the search text was many characters long" would be
returned since "search text" apears exactly as quoted in the search
string.
my approach is to first create two sets of search criteria, those of
any order search words and those quoted for exact matches. to attain
this i was thinking that i would use ereg_replace to first prune out
the non quoted strings using ereg_replace via the call
$searchMinusQuoted = ereg_replace("\"[[:print:]]*\"", "",
$searchString);
and get the quoted stings using the opposite ereg_replace via the call
$serachMinusNonQuoted = ereg_replace("[^\"[[:print:]]*\"]", "",
$serachString);
(or something to that tune)
i am mainly trying to get the first one to work however if there are
two separate quoted strings with a non-quoted string in between like:
hello "text string" another string "foo bar"
the first ereg_replace() turns the string into just:
hello
since it matches the longest pattern possible.
this explaination is probably a bit long winded but i am not sure how
else to explain my problem. if anyone knows how to massage
ereg_replace to get this to work or using another approach all
together, any help would be appreciated.
thanks,
Sean