Re: Google Style Search Results
| From: | Graham Cossey | Date: | Fri, 09 Dec 2005 09:10:52 +0000 |
| Subject: | Re: Google Style Search Results | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40823@lists.php.net to get a copy of this message | ||
On 12/9/05, Julien Bonastre <julien@the-spectrum.org> wrote:
<snip>
>
> http://aries.the-spectrum.org/webdev/wawd/forums/search.php?q=sufficient%2Blarge&st=post&sb%5B%5D=*&maxres=25&ob=datetime&ot=DESC
>
<snip>
>
> All I did was conjure up a regular expression that basically just matches words :-) haha
> ironically..
>
>
> Here it is:
>
> $extract_result="";
> preg_match_all("/((?:[\w]+ ?){0,5})[\w
> \.\,\-\;]((?:".join("|",$q_arr)."))([\w]*)[\w \.\,\-\;]((?:[\w]+
> ?){0,5})/i",$row["content"],$ext_matches,PREG_SET_ORDER);
> foreach($ext_matches as $ext_arr) {
> $extract_result .= $ext_arr[1]."
> <B>".$ext_arr[2]."</B>".$ext_arr[3]." ".$ext_arr[4]." ...
> ";
> }
>
>
> Are you familiar with regex?
>
<snip>
I'm not very familiar with regex at all and was wondering if you could
tell me how your regex would handle two matched search strings that
exist within a few words of each other in the text. For example "A
larger server would be sufficient I think".
Also in the link you provided (reproduced below) the first matched
word is surrounded by 4 words and the second by 5 words, is there a
reason for this?
"An example of a larger post can be found ... we were to add a
sufficient amount of text than we ..."
Thank you.
--
Graham