473,785 Members | 2,325 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
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_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],
$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 1146

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

Similar topics

1
4184
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...
10
2215
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...
3
1555
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….
4
3231
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...
0
1405
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.
7
371
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
25
5169
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
3
2338
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
6
7985
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"
0
9481
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,...
0
10341
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, 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...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9954
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 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...
0
8979
agi2029
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...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.