Hi,. I'm trying to detect any links that are contained within an html page
using eregi pattern matching. I was wondering if there are any pattern
matching geniuses out there who could write a pattern that merges all the
different manners in which a link could be wriiten,
Current patterns I can think of include:
<a href=x.com> no spaces betwen href, equals and url, no quotation marks
around url
<a href =x.com> space between href and equals, no space between equals and
url, no quotation marks round url
<a href= x.com> no space between href and equals, space between equals and
url, no quotation marks around url
<a href = x.com> space between href and equals, space between equals and
url, no quotation marks round url
<a href='x.com'> no spaces betwen href, equals and url, single quotation
marks around url
<a href ='x.com'> space between href and equals, no space between equals and
url, single quotation marks round url
<a href= 'x.com'> no space between href and equals, space between equals and
url, single quotation marks around url
<a href = 'x.com'> space between href and equals, space between equals and
url, single quotation marks round url
<a href="x.com"> no spaces betwen href, equals and url, double quotation
marks around url
<a href ="x.com"> space between href and equals, no space between equals and
url, double quotation marks round url
<a href= "x.com"> no space between href and equals, space between equals and
url, double quotation marks around url
<a href = "x.com"> space between href and equals, space between equals and
url, double quotation marks round url
<a href='x.com"> no spaces betwen href, equals and url, mismatched quotation
marks around url - single open, double to close
<a href ='x.com"> space between href and equals, no space between equals and
url, mismatched quotation marks around url - single open, double to close
<a href= 'x.com"> no space between href and equals, space between equals and
url,mismatched quotation marks around url - single open, double to close
<a href = 'x.com"> space between href and equals, space between equals and
url, mismatched quotation marks around url - single open, double to close
<a href="x.com'> no spaces betwen href, equals and url, mismatched quotation
marks around url - double open, single to close
<a href ="x.com'> space between href and equals, no space between equals and
url, mismatched quotation marks around url - double open, single to close
<a href= "x.com'> no space between href and equals, space between equals and
url,mismatched quotation marks around url - double open, single to close
<a href = "x.com'> space between href and equals, space between equals and
url,mismatched quotation marks around url - double open, single to close
I guess whats needed is something more advanced than
eregi("href=\"/(.*)\">",string ,$arryaholding_ results))
I'd appreciate any help you could give,
Thanks
NimP 1 3800
"NimP" <st*@sturobbie. co.uk> wrote: Hi,. I'm trying to detect any links that are contained within an html page using eregi pattern matching. I was wondering if there are any pattern matching geniuses out there who could write a pattern that merges all the different manners in which a link could be wriiten,
I'm sure there is an easier solution out there somewhere, but by going
through your examples I came up with that (wouldn't validate an URL
though):
preg_match("/<a(\s)+href(\s) *=(\s)*(['\"])*([a-z0-9_\-\.])+(['\"])*>/i",
$string, $matches);
echo htmlentities($m atches[0]);
JOn This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: george |
last post by:
(driving me nuts)
Hi there. I wonder if anyone can help?
I'm including a page from Google in search.php, passing some
parameters. So far so good. Then I'm asking to look through that
Google page for a text match, and return true or false.
eregi returns false whatever the case,
similar_text returns true whatever the case.
Can someone sort me out - oops, HELP me out ?
|
by: Frank |
last post by:
I'm having trouble detecting whitespaces in strings.
Set up this test:
echo "<br>example 1:".intval(eregi("^\s","teststring"));
echo "<br>example 2:".intval(eregi("^\s","test string"));
Both resulting in 0 (zero)
also tried and without result
|
by: Dynamo |
last post by:
Hi
The following script was taken from John Coggeshall's (PHP consultant) in his
article on Zends site at http://www.zend.com/zend/spotlight/ev12apr.php
// Get the email address to validate
$email = $_POST
// Use John Coggeshalls script to validate the email address
if(!eregi("^+(\.+)*@+(\.+)*(\.{2,3})$", $email) {
echo "The e-mail was not valid";
|
by: LRW |
last post by:
I'm trying to make sure a search text field has only numbers, letters, or
spaces.
I started with this:
$pattern = "^()";
if (eregi($pattern, $search_txt)) {
And that works so long as the 1st character isn't a number or letter,
otherwise it allows the whole string.
I did some newsgroup looking, and everything I've found has been for very
|
by: gsv2com |
last post by:
One of my weaknesses has always been pattern matching. Something I
definitely need to study up on and maybe you guys can give me a pointer
here.
I'm looking to remove all of this code and just use pattern matching to
determine if the proper amount of numeric characters has been met. Here is
the function I've already done. Any help you can give in a pattern matching
solution would be much appreciated and very educational.
| |
by: Thomas Reichelt |
last post by:
Moin,
short question: is there any language combining the syntax, flexibility and
great programming experience of Python with static typing? Is there a
project to add static typing to Python?
Thank you,
--
greetz tom
|
by: Xah Lee |
last post by:
# -*- coding: utf-8 -*-
# Python
# Matching string patterns
#
# Sometimes you want to know if a string is of
# particular pattern. Let's say in your website
# you have converted all images files from gif
# format to png format. Now you need to change the
# html code to use the .png files. So, essentially
|
by: Henry |
last post by:
I have a table that stores a list of zip codes using a varchar column type,
and I need to perform some string prefix pattern matching search. Let's say
that I have the columns:
94000-1235
94001
94100
If I run a pattern matching search for the string "940", then I should get
the top two rows of data back. If I run a pattern matching search for the
string "94", then I should get all the three rows of data back.
|
by: olaufr |
last post by:
Hi,
I'd need to perform simple pattern matching within a string using a
list of possible patterns. For example, I want to know if the substring
starting at position n matches any of the string I have a list, as
below:
sentence = "the color is $red"
patterns =
pos = sentence.find($)
|
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: 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...
|
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: 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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |