473,505 Members | 13,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2055

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2773
by: Roland Sippel | last post by:
Is there anything change in "ereg_replace()" PHP > 4.3.2. Scripts works in PHP 4.3.1 but NOT in PHP 4.3.2: $text = "<!-- test -->"; $text = ereg_replace("]+"," ",strip_tags($text)); echo $text...
2
2176
by: Chris | last post by:
Hello, I use a javascript ticker in my header which contains the news in a array like that tickercontents='Message1' tickercontents='Message2' tickercontents='Message3' now i want to write an...
4
2413
by: knocte | last post by:
Hello. I am testing this curious code and I don't understand yet why it doesn't work with the 2nd case: Case 1: $number = "2,4"; $number = ereg_replace(",",".",$number); echo $number; //...
3
2515
by: Xaradas | last post by:
Someone could tell me why preg_replace eat a slash when it do replacement? <? $stringToReplace = "blah blah {nome} blah blah"; $replacement = "Two slash: \\\\"; $stringToReplace =...
0
1087
by: pieterprovoost | last post by:
Hi, I would like to use the ereg_replace() function to replace wiki-like syntax, for example: ] becomes <a href="index.php?page=somepage">somepage</a> **hello** becomes <i>hello</i>
6
536
by: Bob Bedford | last post by:
Hello there, I need help: I've a string that is used to write down a phone number that comes from a form and would like to keep it as clean as possible. For avoiding people to create twice an...
1
4162
by: tmcp | last post by:
Hello I'm a bit new to regular expressions and I'm having a problem I'm trying to strip any code which is inside a <p> tag for instance from <p style="margin: 0in 0in 0pt;" class="MsoNormal"> to...
2
1505
by: encepif | last post by:
I think this is the right command., could someone please show me how to replace instances of a quote like this " with its html version - &quot;. I am mixed up with the escaping, etc. Thank you :-) ...
5
1613
by: Hugh Oxford | last post by:
I have a string that has been saved in a database from a textarea form field. e.g. $text = "Dear %name The date is %date yours,
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.