Author |
Message |
2dragons Novice
Joined: Feb 17 2004 Posts: 95 Offline
|
Posted: Sat Apr 02, 2005 10:25 pm Post maybe stupid Post subject: PHP regex |
 |
|
|
|
I finally had to ask here because I cannot get this to work.
I have something like such:
<?php
$text = '<a href="http://www.somelink.com">';
$text = preg_replace( "<a href=\"(.*?)\">", "\1", $text );
echo $text;
?>
And I'm hoping to get the actual link ie:
http://www.somelink.com
I've never touched regex before, and I've tried numerous patterns:
'/\<a href=\"(.*?)\"\>/'
'/\<a href="(.*?)"\>/'
'\<a href=\"(.*?)\"\>'
'/<a href=\"(.*?)\">/'
But I cannot get anything to work, ideas? |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
|
Back to top |
|
 |
2dragons Novice
Joined: Feb 17 2004 Posts: 95 Offline
|
Posted: Sat Apr 02, 2005 10:54 pm Post maybe stupid Post subject: |
 |
|
|
|
Thanks for the reply, I've been use Regex Coach for awhile, it definently helps.
But did you actually try that within php?
It does not work for me, and I had attempted that before. |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Sun Apr 03, 2005 12:04 am Post maybe stupid Post subject: |
 |
|
|
|
Worked fine for me when tried it out. The server I tried it on is running PHP/4.3.10. |
|
Back to top |
|
 |
Cerium Server Help Squatter

Age:43 Gender: Joined: Mar 05 2005 Posts: 807 Location: I will stab you. Offline
|
|
Back to top |
|
 |
2dragons Novice
Joined: Feb 17 2004 Posts: 95 Offline
|
Posted: Sun Apr 03, 2005 1:05 am Post maybe stupid Post subject: |
 |
|
|
|
Well I did give yours a shot Cerium and it does work, however I now believe my problem lies within the actual bit of text I'm trying to use it on.
<font title="verdana"><a href="http://www.host.com/abc3.cfm?abc3id=180&distID=78&abc3src=link">
<img align="center" style="float: left; margin: 0px 10px 0px 0px;" src="http://www.host.com/abc3/servlet/Download?filename=/medialocker/180/coverart/Album-75.jpg" border="0" ALT="Battleground by Colorado Symphony Orchestra" width="75" height="75">
<br /><br />Battleground by Colorado Symphony Orchestra</a></font> |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Sun Apr 03, 2005 1:20 am Post maybe stupid Post subject: |
 |
|
|
|
Playing around in Regex Coach, if you have it all be on a single line (the s flag), it works fine. Try that in php real quick. Else, /<A [^>]*HREF=\"(.*?)\"[^>]*>/i works fine. |
|
Back to top |
|
 |
Chambahs Guest
Offline
|
Posted: Sun Apr 03, 2005 9:49 am Post maybe stupid Post subject: |
 |
|
|
|
hey 2dragons, when are ya gonna be done with the SSI biller? (bump) |
|
Back to top |
|
 |
|