Re: [PHP] Regex Help for URL's [ANSWER]

2006-05-17 Thread Edward Vermillion


On May 16, 2006, at 7:53 PM, Chrome wrote:


-Original Message-
From: Robert Samuel White [mailto:[EMAIL PROTECTED]
Sent: 17 May 2006 01:42
To: php-general@lists.php.net
Subject: RE: [PHP] Regex Help for URL's [ANSWER]



That's what I was doing.  I was parsing A:HREF, IMG:SRC, etc.

But when I implemented a new feature on my network, where you  
could click

on
a row and have it take you to another domain, I need a better  
solution.


Go to http://www.enetwizard.ws and it might make more sense.

All the links on the left have an ONCLICK=location.href = ''  
attribute in

the TR tag.

This solution allowed me to make sure those links included the  
session

information, just like the A:HREF links do.

It also had the advantage of updating the links in my CSS.


O that breaks accessibility standards! Compliment the  
'onclick's with

onkeydown at least :)

But still you get a solid onclick=... scenario

If these are visible in the source then they are fairly easy to  
pick out


Though you may need more than 1 regex ;)

My complaint here is, don't break accessibility :)



And don't forget the folks who have javascript turned off or are  
using text based browsers too.


Ed

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Regex Help for URL's

2006-05-17 Thread Kevin Waterson
This one time, at band camp, Robert Samuel White [EMAIL PROTECTED] wrote:

 Don't be rude.  I've already don't all of that.  Nothing came up.  I've been
 programming for 20 years (since I was 11 years old) so I'm not a slacker
 when it comes to learning new things, however, I have always found regular
 expressions to be extremely difficult.  Someone here might have the answer I
 need, and if so, I'd appreciate a response.  If you don't know the answer,
 don't reply.  Simple enough, don't you think?

Sorry, I missed most of this...
From what I gather you wish to extract urls from text?
if so..
function getLinks($string){
  // regex to get the links
  preg_match_all(|http:?([^\' ]+)|i, $string, $arrayoflinks);
  return $arrayoflinks;
}

Also check out this on line tutorial for regex geared towards PHP
http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html

Kind regards
Kevin

-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Regex Help for URL's

2006-05-16 Thread Jochem Maas

Robert Samuel White wrote:

Can someone help me modify the following code?

It was designed to search for all instances of [LEVEL#]...[/LEVEL#]

I need a preg_match_all that will search for all of instances of an URL.

It should be sophisticated enough to find something as complicated as this:

http(s)://x.y.z.domain.com/dir/dir/file.name.ext?query=1query=2#anchor

Any help would be greatly appreciated!


so your looking for a regular expression that is *totally* different
from the regular expression you have... the two have nothing in common.

do you expect us to do the complete rewrite for you or do you want to
learn abit about regexps yourself? (that probably sounds arrogant, so it might
help to know even the most experienced people (a group I don't consider myself
part of) here have [and do] get told to RTFM on occasion - no one is safe ;-)

I suggest using a search engine to start with and see what that turns up...
somehow I can't believe that nobody has ever written a regexp that matches urls,
for instance try reading this page in the manual (hint: look at the the user 
notes)

http://php.net/preg_match

come back when/if you get stuck.



preg_match_all('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim', $arcContent,
$tmpMatches);

$arcContent = preg_replace('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim',
'###URL###', $arcContent); 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's

2006-05-16 Thread Robert Samuel White
Don't be rude.  I've already don't all of that.  Nothing came up.  I've been
programming for 20 years (since I was 11 years old) so I'm not a slacker
when it comes to learning new things, however, I have always found regular
expressions to be extremely difficult.  Someone here might have the answer I
need, and if so, I'd appreciate a response.  If you don't know the answer,
don't reply.  Simple enough, don't you think?

-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 16, 2006 4:28 PM
To: Robert Samuel White
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex Help for URL's

Robert Samuel White wrote:
 Can someone help me modify the following code?
 
 It was designed to search for all instances of [LEVEL#]...[/LEVEL#]
 
 I need a preg_match_all that will search for all of instances of an URL.
 
 It should be sophisticated enough to find something as complicated as
this:
 
 http(s)://x.y.z.domain.com/dir/dir/file.name.ext?query=1query=2#anchor
 
 Any help would be greatly appreciated!

so your looking for a regular expression that is *totally* different
from the regular expression you have... the two have nothing in common.

do you expect us to do the complete rewrite for you or do you want to
learn abit about regexps yourself? (that probably sounds arrogant, so it
might
help to know even the most experienced people (a group I don't consider
myself
part of) here have [and do] get told to RTFM on occasion - no one is safe
;-)

I suggest using a search engine to start with and see what that turns up...
somehow I can't believe that nobody has ever written a regexp that matches
urls,
for instance try reading this page in the manual (hint: look at the the user
notes)

http://php.net/preg_match

come back when/if you get stuck.

 
 preg_match_all('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim', $arcContent,
 $tmpMatches);
 
 $arcContent = preg_replace('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim',
 '###URL###', $arcContent); 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's

2006-05-16 Thread Robert Cummings
On Tue, 2006-05-16 at 16:31, Robert Samuel White wrote:
 Don't be rude.  I've already don't all of that.  Nothing came up.  I've been
 programming for 20 years (since I was 11 years old) so I'm not a slacker
 when it comes to learning new things, however, I have always found regular
 expressions to be extremely difficult.  Someone here might have the answer I
 need, and if so, I'd appreciate a response.  If you don't know the answer,
 don't reply.  Simple enough, don't you think?

Perhaps a tad rude, but I got a treasure trove of hits from Google in my
first shot:

   
http://www.google.ca/search?hl=enq=regex+extract+urls+from+contentbtnG=Google+Searchmeta=

Formulating a good search query is a great skill to hone.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Regex Help for URL's

2006-05-16 Thread John Nichel

Robert Samuel White wrote:

Don't be rude.  I've already don't all of that.  Nothing came up.  I've been
programming for 20 years (since I was 11 years old) so I'm not a slacker
when it comes to learning new things, however, I have always found regular
expressions to be extremely difficult.  Someone here might have the answer I
need, and if so, I'd appreciate a response.  If you don't know the answer,
don't reply.  Simple enough, don't you think?


What's simple is a Google search.

If you don't want to do the leg work, don't ask us to do it for.  Simple 
enough, don't you think.


Because it makes the email hard to read.
Why is top posting bad?


-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 16, 2006 4:28 PM

To: Robert Samuel White
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex Help for URL's

Robert Samuel White wrote:

Can someone help me modify the following code?

It was designed to search for all instances of [LEVEL#]...[/LEVEL#]

I need a preg_match_all that will search for all of instances of an URL.

It should be sophisticated enough to find something as complicated as

this:

http(s)://x.y.z.domain.com/dir/dir/file.name.ext?query=1query=2#anchor

Any help would be greatly appreciated!


so your looking for a regular expression that is *totally* different
from the regular expression you have... the two have nothing in common.

do you expect us to do the complete rewrite for you or do you want to
learn abit about regexps yourself? (that probably sounds arrogant, so it
might
help to know even the most experienced people (a group I don't consider
myself
part of) here have [and do] get told to RTFM on occasion - no one is safe
;-)

I suggest using a search engine to start with and see what that turns up...
somehow I can't believe that nobody has ever written a regexp that matches
urls,
for instance try reading this page in the manual (hint: look at the the user
notes)

http://php.net/preg_match

come back when/if you get stuck.


preg_match_all('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim', $arcContent,
$tmpMatches);

$arcContent = preg_replace('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim',
'###URL###', $arcContent); 






--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's

2006-05-16 Thread Robert Samuel White
I am trying to get all of the urls in a web document, so that I can append
information to the urls when needed (when the url points to a domain that
resides on my server).  It allows me to pass session information across the
domains of my network.  Currently, I use a class I wrote to handle this, but
it only works when it finds the urls in a standard html tag.  I need to
expand upon this, so that it also finds urls that are in onclick events, for
example.  Here is a sample page from my website:


SCRIPT LANGUAGE=JavaScriptif (parent != self) top.location.href =
location.href;/SCRIPTTABLE WIDTH=1000 BORDER=0 CELLPADDING=0
CELLSPACING=0 ALIGN=CENTER CLASS=TEMPLATE-TABLETRTD COLSPAN=7
CLASS=TEMPLATE-TABLE-TOP
TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% HEIGHT=48
TR
TD WIDTH=60 ROWSPAN=2 ALIGN=RIGHTIMG
SRC=http://www.enetwizard.info/shared/enetwizard.gif; WIDTH=46
HEIGHT=46 BORDER=0 ALT= //TD
TD HEIGHT=24 VALIGN=BOTTOMDIV STYLE=font-family: sans-serif;
font-size: 8pt; font-weight: bold; color: white; margin-left:
10px;eNetwizard, Inc./DIV/TD
TD HEIGHT=24 VALIGN=BOTTOM ALIGN=RIGHTDIV STYLE=font-family:
sans-serif; font-size: 8pt; color: #FF; font-weight: bold; margin-right:
20px;
Anonymous Visitornbsp;nbsp;|nbsp;nbsp;A
HREF=http://www.enetwizard.cc/security.wizard?asset=welcomeamp;process=log
inamp;form=login STYLE=font-family: sans-serif; font-size: 8pt; color:
#6BDB17; font-weight: bold; text-decoration: underline;Log
In/Anbsp;nbsp;|nbsp;nbsp;A
HREF=http://www.enetwizard.cc/security.wizard?asset=welcomeamp;process=sig
nupamp;form=signup STYLE=font-family: sans-serif; font-size: 8pt; color:
#6BDB17; font-weight: bold; text-decoration: underline;Sign Up/A
/DIV/TD

/TRTR
TD HEIGHT=24 VALIGN=TOPDIV STYLE=font-family: sans-serif; font-size:
8pt; color: white; margin-left: 10px;IEmpowering Your
Creativity./I/DIV/TD
TD HEIGHT=24 VALIGN=TOP ALIGN=RIGHTDIV STYLE=font-family:
sans-serif; font-size: 8pt; color: #FF; margin-right: 20px;
ITuesday, May 16, 2006/I
/DIV/TD
/TR
/TABLE
/TD/TRTRTD COLSPAN=7 STYLE=height: 20px;DIV STYLE=font-size:
1px;nbsp;/DIV/TD/TRTRTD VALIGN=TOP STYLE=width: 20px;DIV
STYLE=font-size: 1px;nbsp;/DIV/TDTD VALIGN=TOP
CLASS=TEMPLATE-TABLE-LEFT STYLE=width: 180px;TABLE
CLASS=RSW-TABLETR CLASS=RSW-TABLE-HEAD-TRTD
CLASS=RSW-TABLE-HEAD-TDDIV CLASS=RSW-DIV-HEAD-CENTERSPAN
CLASS=RSW-FONT-HEAD-TEXTeNetwizard, Inc./SPAN/DIV/TD/TRTR
CLASS=RSW-TABLE-ROW1-TRTD CLASS=RSW-TABLE-ROW1-TD
ONMOUSEOVER=this.className = 'RSW-TABLE-SEP1-TD'; window.status = 'Backend
Manager'; return true; ONMOUSEOUT=this.className = 'RSW-TABLE-ROW1-TD';
window.status = ''; return true; ONCLICK=location.href =
'http://www.enetwizard.be/default.rsw'; return true; STYLE=cursor:
pointer;DIV CLASS=RSW-DIV-ROW1-LEFTSPAN CLASS=RSW-FONT-ROW1-TEXTA
CLASS=RSW-FONT-ROW1-LINK HREF=http://www.enetwizard.be/default.rsw;
ONMOUSEOVER=window.status = 'Backend Manager'; return true;
ONMOUSEOUT=window.status = ''; return true;Backend
Manager/ABReNetwizard.be/SPAN/DIV/TD/TRTR
CLASS=RSW-TABLE-ROW2-TRTD CLASS=RSW-TABLE-ROW2-TD
ONMOUSEOVER=this.className = 'RSW-TABLE-SEP2-TD'; window.status = 'Business
Headquarters'; return true; ONMOUSEOUT=this.className =
'RSW-TABLE-ROW2-TD'; window.status = ''; return true;
ONCLICK=location.href = 'http://www.enetwizard.biz/default.rsw'; return
true; STYLE=cursor: pointer;DIV CLASS=RSW-DIV-ROW2-LEFTSPAN
CLASS=RSW-FONT-ROW2-TEXTA CLASS=RSW-FONT-ROW2-LINK
HREF=http://www.enetwizard.biz/default.rsw; ONMOUSEOVER=window.status =
'Business Headquarters'; return true; ONMOUSEOUT=window.status = '';
return true;Business
Headquarters/ABReNetwizard.biz/SPAN/DIV/TD/TRTR
CLASS=RSW-TABLE-SEP1-TRTD CLASS=RSW-TABLE-SEP1-TD
ONMOUSEOVER=this.className = 'RSW-TABLE-SEP1-TD'; window.status = 'Client
Control Center'; return true; ONMOUSEOUT=this.className =
'RSW-TABLE-SEP1-TD'; window.status = ''; return true;
ONCLICK=location.href = 'http://www.enetwizard.cc/default.rsw'; return
true; STYLE=cursor: pointer;DIV CLASS=RSW-DIV-SEP1-LEFTSPAN
CLASS=RSW-FONT-SEP1-TEXTA CLASS=RSW-FONT-SEP1-LINK
HREF=http://www.enetwizard.cc/default.rsw; ONMOUSEOVER=window.status =
'Client Control Center'; return true; ONMOUSEOUT=window.status = '';
return true;Client Control
Center/ABReNetwizard.cc/SPAN/DIV/TD/TRTR
CLASS=RSW-TABLE-ROW2-TRTD CLASS=RSW-TABLE-ROW2-TD
ONMOUSEOVER=this.className = 'RSW-TABLE-SEP2-TD'; window.status =
'Development Services'; return true; ONMOUSEOUT=this.className =
'RSW-TABLE-ROW2-TD'; window.status = ''; return true;
ONCLICK=location.href = 'http://www.enetwizard.de/default.rsw'; return
true; STYLE=cursor: pointer;DIV CLASS=RSW-DIV-ROW2-LEFTSPAN
CLASS=RSW-FONT-ROW2-TEXTA CLASS=RSW-FONT-ROW2-LINK
HREF=http://www.enetwizard.de/default.rsw; ONMOUSEOVER=window.status =
'Development Services'; return true; ONMOUSEOUT=window.status = ''; return
true;Development Services/ABReNetwizard.de/SPAN/DIV/TD/TRTR
CLASS=RSW-TABLE-ROW1-TRTD CLASS=RSW-TABLE-ROW1-TD
ONMOUSEOVER=this.className = 'RSW-TABLE-SEP1-TD'; window.status = 

Re: [PHP] Regex Help for URL's

2006-05-16 Thread Jochem Maas

Robert Samuel White wrote:

Don't be rude.  I've already don't all of that.  Nothing came up.  I've been
programming for 20 years (since I was 11 years old) so I'm not a slacker
when it comes to learning new things, however, I have always found regular
expressions to be extremely difficult.  Someone here might have the answer I
need, and if so, I'd appreciate a response.  If you don't know the answer,
don't reply.  Simple enough, don't you think?


I wasn't being rude. Although even If I was commanding me stop is rather
futile no? if I was being rude I would have said something like:

read http://php.net/preg_match and find the get_links() function
 posted by 'max99x [at] gmail [dot] com'  you f*** wit

now that would have been rude.

the argument that the length of time spent programming automatically
makes you 'not a slacker' is unbased. one does not equate the other.
personally I would assume anyone who had been programming for 20 yrs
would have a reasonable understanding of regexps.



-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 16, 2006 4:28 PM

To: Robert Samuel White
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex Help for URL's

Robert Samuel White wrote:


Can someone help me modify the following code?

It was designed to search for all instances of [LEVEL#]...[/LEVEL#]

I need a preg_match_all that will search for all of instances of an URL.

It should be sophisticated enough to find something as complicated as


this:


http(s)://x.y.z.domain.com/dir/dir/file.name.ext?query=1query=2#anchor

Any help would be greatly appreciated!



so your looking for a regular expression that is *totally* different
from the regular expression you have... the two have nothing in common.

do you expect us to do the complete rewrite for you or do you want to
learn abit about regexps yourself? (that probably sounds arrogant, so it
might
help to know even the most experienced people (a group I don't consider
myself
part of) here have [and do] get told to RTFM on occasion - no one is safe
;-)

I suggest using a search engine to start with and see what that turns up...
somehow I can't believe that nobody has ever written a regexp that matches
urls,
for instance try reading this page in the manual (hint: look at the the user
notes)

http://php.net/preg_match

come back when/if you get stuck.



preg_match_all('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim', $arcContent,
$tmpMatches);

$arcContent = preg_replace('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim',
'###URL###', $arcContent); 






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's

2006-05-16 Thread Chrome
 -Original Message-
 From: Robert Samuel White [mailto:[EMAIL PROTECTED]
 Sent: 16 May 2006 21:32
 To: php-general@lists.php.net
 Subject: RE: [PHP] Regex Help for URL's
 
 Don't be rude.  I've already don't all of that.  Nothing came up.  I've
 been
 programming for 20 years (since I was 11 years old) so I'm not a slacker
 when it comes to learning new things, however, I have always found regular
 expressions to be extremely difficult.  Someone here might have the answer
 I
 need, and if so, I'd appreciate a response.  If you don't know the answer,
 don't reply.  Simple enough, don't you think?
 -Original Message-
 From: Jochem Maas [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, May 16, 2006 4:28 PM
 To: Robert Samuel White
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Regex Help for URL's
 
 Robert Samuel White wrote:
  Can someone help me modify the following code?
 
  It was designed to search for all instances of [LEVEL#]...[/LEVEL#]
 
  I need a preg_match_all that will search for all of instances of an URL.
 
  It should be sophisticated enough to find something as complicated as
 this:
 
  http(s)://x.y.z.domain.com/dir/dir/file.name.ext?query=1query=2#anchor
 
  Any help would be greatly appreciated!
 
 so your looking for a regular expression that is *totally* different
 from the regular expression you have... the two have nothing in common.
 
 do you expect us to do the complete rewrite for you or do you want to
 learn abit about regexps yourself? (that probably sounds arrogant, so it
 might
 help to know even the most experienced people (a group I don't consider
 myself
 part of) here have [and do] get told to RTFM on occasion - no one is safe
 ;-)
 
 I suggest using a search engine to start with and see what that turns
 up...
 somehow I can't believe that nobody has ever written a regexp that matches
 urls,
 for instance try reading this page in the manual (hint: look at the the
 user
 notes)
 
   http://php.net/preg_match
 
 come back when/if you get stuck.
 
 
  preg_match_all('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim', $arcContent,
  $tmpMatches);
 
  $arcContent = preg_replace('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim',
  '###URL###', $arcContent);
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 __ NOD32 1.1541 (20060516) Information __
 
 This message was checked by NOD32 antivirus system.
 http://www.eset.com

Bearing in mind that none of the replies (particularly that of Jochem, one
of the posters that should be held in high regard) have been rude in any way
at all, I understand your plight with regex's

You might want to try the Regex Coach... It allows you to test your regex's
offline and can really help

http://www.weitz.de/regex-coach/

HTH

Dan

Personal note: Stop using Lookout... it sucks

-- 
http://chrome.me.uk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's [ANSWER]

2006-05-16 Thread Robert Samuel White
In case any one is looking for a solution to a similar problem as me, here
is the answer.  I used the code from my original post as my guiding light,
and with some experimentation, I figured it out.

To get any URL, regardless of where it is located, use this:

preg_match_all(#\'http://(.*)\'#U, $content, $matches);

This match anything similar to:

'http://www.domain.com/dir/dir/file.txt?query=blah'

This is useful, if for example, you have a tag like this one:

A HREF=javascript:void(0); ONCLICK=javascript:window.open =
'http://www.domain.com/dir/dir/file.txt?query=blah';

Now, for tags which are in quotes, rather than single quotes, just use:

preg_match_all(#\http://(.*)\#U, $content, $matches);


This is really only the first step.

In order to be useful, you need a way to process these urls according to
your own specific needs:

preg_match_all(#\'http://(.*)\'#U, $content, $matches);

$content = preg_replace(#\'http://(.*)\'#U, '###URL###', $content);

This will modify the $content variable to change all urls to ###URL###

You can then go through them one at a time to process them:

for ($count = 0; $count  count($matches[1]); $count++)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's [ANSWER]

2006-05-16 Thread Robert Cummings
On Tue, 2006-05-16 at 18:49, Robert Samuel White wrote:
 In case any one is looking for a solution to a similar problem as me, here
 is the answer.  I used the code from my original post as my guiding light,
 and with some experimentation, I figured it out.
 
 To get any URL, regardless of where it is located, use this:
 
 preg_match_all(#\'http://(.*)\'#U, $content, $matches);
 
 This match anything similar to:
 
 'http://www.domain.com/dir/dir/file.txt?query=blah'
 
 This is useful, if for example, you have a tag like this one:
 
 A HREF=javascript:void(0); ONCLICK=javascript:window.open =
 'http://www.domain.com/dir/dir/file.txt?query=blah';
 
 Now, for tags which are in quotes, rather than single quotes, just use:
 
 preg_match_all(#\http://(.*)\#U, $content, $matches);

I'd roll those two into one expression:

preg_match_all(#(\|')http://(.*)(\|')#U, $content, $matches);

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's [ANSWER]

2006-05-16 Thread Richard Lynch
On Tue, May 16, 2006 6:21 pm, Robert Cummings wrote:
 On Tue, 2006-05-16 at 18:49, Robert Samuel White wrote:
 In case any one is looking for a solution to a similar problem as
 me, here
 preg_match_all(#(\|')http://(.*)(\|')#U, $content, $matches);

And it's missing the original requirement of matching https URLs, so
maybe make it be ...https?://...

Plus, http could be IN CAPS, so change the U to iU

And, actually, SOME old-school HTML pages will have neither ' nor 
around the URL, and are (or were) valid:
href=page2.html
was considered valid for HTML for a long long long time
So toss in (\|')?
And then you may be finding URLs that are not actually linked but are
part of the visible content, so maybe you only want the ones that
have
a[^]href=
in front of them.

If I can toss off 3 problems without even trying...

So I still think Google or searching the archives (as I suggested
off-list) will be the quickest route to a CORRECT answer, but here we
are again in this same thread we've been in every month or so for the
better part of a decade...

PS the (\|') bit may move the URLs into $matches[2] instead of
$matches[1] or whatever.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's [ANSWER]

2006-05-16 Thread Robert Samuel White
All pages used by my content management system must be in a valid format.

Old-school style pages are never created so the solution I have come up with
is perfect for my needs.

Thank you.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's [ANSWER]

2006-05-16 Thread Chrome

 -Original Message-
 From: Robert Samuel White [mailto:[EMAIL PROTECTED]
 Sent: 17 May 2006 01:16
 To: php-general@lists.php.net
 Subject: RE: [PHP] Regex Help for URL's [ANSWER]
 
 All pages used by my content management system must be in a valid format.
 
 Old-school style pages are never created so the solution I have come up
 with
 is perfect for my needs.
 
 Thank you.

Doesn't that make it a proprietary solution? IMHO offering the regex may
create a false situation for people... So the answer may not be for everyone

Might be wrong :)

Dan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Regex Help for URL's

2006-05-16 Thread Richard Lynch
On Tue, May 16, 2006 4:22 pm, Jochem Maas wrote:
 personally I would assume anyone who had been programming for 20 yrs
 would have a reasonable understanding of regexps.

Nope.

:-)

I got WAY past 20 year mark before I even began to pretend to
understand the minimal amount of regex I can do now.

Most things complicated enough to need regex are too complicated to do
with regex, if you know what I mean...

There's a very narrow band of problems where I'm comfy with regex,
really.

Anything simpler than that is just a substr or explode.

Anything more complicated, and I just don't want to try to maintain
the mess of not-quite-random characters needed to make a so-called
pattern and I'll find some other way to break the problem down into
sub-problems.

Those sub-problems might then be amenable to a reasonable regex, of
course, but I'm just not gonna tackle it in one big messy pattern.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's [ANSWER]

2006-05-16 Thread Robert Samuel White
In my opinion, it is the most reasonable solution.  I have looked all over
the web for something else, but this works perfectly for me.  It's
impossible to tell where an url starts and ends if you don't have it in
quotes or single quotes.  If someone really needs to find all the urls in a
page, then they'll code their pages to make use of this limitation.

-Original Message-
From: Chrome [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 16, 2006 8:24 PM
To: 'Robert Samuel White'; php-general@lists.php.net
Subject: RE: [PHP] Regex Help for URL's [ANSWER]


 -Original Message-
 From: Robert Samuel White [mailto:[EMAIL PROTECTED]
 Sent: 17 May 2006 01:16
 To: php-general@lists.php.net
 Subject: RE: [PHP] Regex Help for URL's [ANSWER]
 
 All pages used by my content management system must be in a valid format.
 
 Old-school style pages are never created so the solution I have come up
 with
 is perfect for my needs.
 
 Thank you.

Doesn't that make it a proprietary solution? IMHO offering the regex may
create a false situation for people... So the answer may not be for everyone

Might be wrong :)

Dan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's [ANSWER]

2006-05-16 Thread Chrome
 -Original Message-
 From: Robert Samuel White [mailto:[EMAIL PROTECTED]
 Sent: 17 May 2006 01:28
 To: php-general@lists.php.net
 Subject: RE: [PHP] Regex Help for URL's [ANSWER]
 
 In my opinion, it is the most reasonable solution.  I have looked all over
 the web for something else, but this works perfectly for me.  It's
 impossible to tell where an url starts and ends if you don't have it in
 quotes or single quotes.  If someone really needs to find all the urls in
 a
 page, then they'll code their pages to make use of this limitation.
 
 -Original Message-
 From: Chrome [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, May 16, 2006 8:24 PM
 To: 'Robert Samuel White'; php-general@lists.php.net
 Subject: RE: [PHP] Regex Help for URL's [ANSWER]
 
 
  -Original Message-
  From: Robert Samuel White [mailto:[EMAIL PROTECTED]
  Sent: 17 May 2006 01:16
  To: php-general@lists.php.net
  Subject: RE: [PHP] Regex Help for URL's [ANSWER]
 
  All pages used by my content management system must be in a valid
 format.
 
  Old-school style pages are never created so the solution I have come up
  with
  is perfect for my needs.
 
  Thank you.
 
 Doesn't that make it a proprietary solution? IMHO offering the regex may
 create a false situation for people... So the answer may not be for
 everyone
 
 Might be wrong :)
 
 Dan
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 __ NOD32 1.1542 (20060516) Information __
 
 This message was checked by NOD32 antivirus system.
 http://www.eset.com

If we are talking clickable links, why not focus on the a construct
itself? Otherwise URLs are just part of the page's textual content... Very
difficult to parse that

Disseminating an a tag isn't brain-meltingly difficult with a regex if you
put your mind to it... With or without quotes, be they single, double or
non-existent


If I've misunderstood please chastise me :)

HTH

Dan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's [ANSWER]

2006-05-16 Thread Robert Samuel White

 If we are talking clickable links, why not focus on the a construct
 itself? Otherwise URLs are just part of the page's textual content... Very
 difficult to parse that

 Disseminating an a tag isn't brain-meltingly difficult with a regex if
 you put your mind to it... With or without quotes, be they single, double 
 or non-existent

If I've misunderstood please chastise me :)

HTH

Dan


Dan,

That's what I was doing.  I was parsing A:HREF, IMG:SRC, etc.

But when I implemented a new feature on my network, where you could click on
a row and have it take you to another domain, I need a better solution.

Go to http://www.enetwizard.ws and it might make more sense.

All the links on the left have an ONCLICK=location.href = '' attribute in
the TR tag.

This solution allowed me to make sure those links included the session
information, just like the A:HREF links do.

It also had the advantage of updating the links in my CSS.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex Help for URL's [ANSWER]

2006-05-16 Thread Chrome
 -Original Message-
 From: Robert Samuel White [mailto:[EMAIL PROTECTED]
 Sent: 17 May 2006 01:42
 To: php-general@lists.php.net
 Subject: RE: [PHP] Regex Help for URL's [ANSWER]
 
 
  If we are talking clickable links, why not focus on the a construct
  itself? Otherwise URLs are just part of the page's textual content...
 Very
  difficult to parse that
 
  Disseminating an a tag isn't brain-meltingly difficult with a regex if
  you put your mind to it... With or without quotes, be they single,
 double
  or non-existent
 
 If I've misunderstood please chastise me :)
 
 HTH
 
 Dan
 
 
 Dan,
 
 That's what I was doing.  I was parsing A:HREF, IMG:SRC, etc.
 
 But when I implemented a new feature on my network, where you could click
 on
 a row and have it take you to another domain, I need a better solution.
 
 Go to http://www.enetwizard.ws and it might make more sense.
 
 All the links on the left have an ONCLICK=location.href = '' attribute in
 the TR tag.
 
 This solution allowed me to make sure those links included the session
 information, just like the A:HREF links do.
 
 It also had the advantage of updating the links in my CSS.

O that breaks accessibility standards! Compliment the 'onclick's with
onkeydown at least :)

But still you get a solid onclick=... scenario

If these are visible in the source then they are fairly easy to pick out

Though you may need more than 1 regex ;)

My complaint here is, don't break accessibility :)

Dan


-- 
http://chrome.me.uk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php