473,688 Members | 3,175 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
if(preg_match_a ll("/((\s\S*){0,3})( $keyword)
((\s?\S*){0,3})/i", $portion, $match, PREG_SET_ORDER) );
if(!$limit_extr acts)
$number=count($ match);
else $number=$limit_ extracts;

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

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

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



Feb 27 '07 #1
0 1140

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

Similar topics

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 regular expressions easier to create and use (and in my experience as a regular expression user, it makes them MUCH easier to create and use.) I'm still working on formal documentation, and in any case, such documentation isn't necessarily the...
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 and isNaN, but I'm not even sure that the results are as perfect as I need. I am expecting to use RegExp.test(string), but I'm not 100% sure about that, either. Here is a test program with a textbox that has a maxlength of 2 characters. The...
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 is a way to do it with regular expression. Does someone know how to do it ? Please help….
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 over each document, find out if it contains a header and/or a footer and extract only the main content part. The headers and the footers have no specific format and I have to detect and remove them using a list of strings that may appear as...
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 because mail clients like outlook ect give messages about not being able to display it properly.
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 - Album- i have try this syntax but it failed
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 (CONDUCTION DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH CATHETER 37.34/2 " the expression is "HEART (CONDUCTION DEFECT)". How do I gain access to the expression (not the matches) at runtime? Thanks, Mike
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: john@MyDomain.com andrew@MyDomain.com marysmith@MyDomain.com
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 work, would somebody be so kind as to tell me why. <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.