473,320 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Regular Expression Detecting Entire Page

Excuse the babbling or lack of sense, it's been a long day.

I am making a flat file, static HTML search engine for a site. I
downloaded a script from the net and have been working with it for my
needs.

Everything was working OK with a few test Lorem Ipsum pages. But the
moment I try to search real data, fit hits the shan.

The script uses a regular expression to search through the files. And
for most of these files, the regular expression doesnt seem to pick up
the matches as it should, and for lack of a match, it outputs the
entire html page as a hit. The search word is on the page somewhere,
but it still outputs the entire page.

Allow me
--------8<----------------------------
if(preg_match_all("/((\s\S*){0,3})($keyword)
((\s?\S*){0,3})/i", $portion, $match, PREG_SET_ORDER));
{
if(!$limit_extracts)
$number=count($match);
else $number=$limit_extracts;

for ($h=0;$h<$number;$h++){ // no limit
if (!empty($match[$h][3]))
$text = sprintf("... %s<font
class='keyword'>%s</font>%s ...", $match[$h][1], $match[$h][3],
$match[$h][4]);
else{
//print_r($match);
}
}
}
--------8<----------------------------

There's the regex that looks through $portion, which is the strip_tags
version of the file's contents. And if I echo $portion right before
that line, I see the stripped code. However, when I get to the line
where it checks $match[$h][3] for the keyword that was searched for,
it craps out. Not 100% of the time, but most of the time. Im trying
to figure out details about these html pages, to no avail.
So as a result of failing that empty test, the entire html page is
dumped out as a search result.

Not being a regex expert, Ive had a hell of time troubleshooting. But
I feel the problem lies in there. Something with the regex not finding
the keyword correctly, or something.

I hope this was clear enough for someone to point me in the right
direction. I'm gonna get some sleep and answer any questions anyone
may have.

Oh here's the URL
http://www.bridgeportarena.com/search_test/form.php

Search for "office", you'll get an idea of what I mean.

Thanks

-peter

Feb 27 '07 #1
0 1123

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

Similar topics

1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
10
by: Jeff Sandler | last post by:
I have a page that accepts input from many textboxes. Many of the textboxes are intended to accept dates and times, thus, I expect only digits to be entered. I originally tested using parseInt...
3
by: Ori | last post by:
Hi , I'm working with C#.NET and I'm looking for the following. I have a web page content and I want to pull all the text which appear in the page without all the HTML tags. I know that there...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
0
by: Martin | last post by:
Hi, I am working on a function to email my entire web page. I have so far achieved this, however I am having problems removing all script from the HTML of the page. I wish to remove script...
7
by: norton | last post by:
Hello, Does any one know how to extact the following text into 4 different groups(namely Date, Artist, Album and Quality)? - Artist - Album Artist - Album - Artist - Album - Artist -...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
3
by: shapper | last post by:
Hello, I have a regular expression to validate email addresses: "\w+(\w+)*@\w+(\w+)*\.\w+(\w+)*" Now I need to force all emails to be from a given domain, for example, accept only:...
6
by: David | last post by:
I'm having trouble getting the regular expression validator to work with a text box. In this simple example I only want lower case letters to be allowed. So I tried the following and it doesn't...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.