470,874 Members | 1,435 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,874 developers. It's quick & easy.

ereg_replace

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
Jul 17 '05 #1
0 1864

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Roland Sippel | last post: by
2 posts views Thread by Chris | last post: by
4 posts views Thread by knocte | last post: by
3 posts views Thread by Xaradas | last post: by
reply views Thread by pieterprovoost | last post: by
6 posts views Thread by Bob Bedford | last post: by
1 post views Thread by tmcp | last post: by
2 posts views Thread by encepif | last post: by
5 posts views Thread by Hugh Oxford | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.