Bluehost.com Web Hosting $6.95

PHP eregi_replace Why doesn't it...

This is a discussion on PHP eregi_replace Why doesn't it... within the PHP General forums, part of the PHP Programming Forums category; Greetings, I'm stumped and was hoping one of you out there can give me a hand. I found some ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-12-2003
Ryan
 
Posts: n/a
Default PHP eregi_replace Why doesn't it...

Greetings,

I'm stumped and was hoping one of you out there can give me a hand.

I found some code on php.net that changes
<a href=http://www.somesite.com>Somesite</a>
into
Somesite
Which is perfect. It handles multiple links and everything. The
problem I'm having is trying to change it back into the links.

By simple reasoning, I figured I'd just have to change a little bit of
the working code to make it work, but it doesn't.

I'm no expert, as you can probably guess, but I've been working on
this for days now and I still can't seem to get it.

Any help is much appreciated,
Ryan

Here is the code that works: (Found it at php.net)
$website = eregi_replace('(<a [^<]*href=["|\']?([^
"\']*)["|\']?[^>]*>([^<]*)</a>)','\\3', $website);

Here is what I'm working with:
$website = eregi_replace('\[url=("|\')?([^
"\']*)("|\')?.*\]([^<]*)\[/URL\]', '<A HREF=\\2>\\4</A>', $website);
Reply With Quote
  #2 (permalink)  
Old 08-18-2003
Ryan
 
Posts: n/a
Default Re: PHP eregi_replace Why doesn't it...

Well, I figured out something but it only prints out the last
occurance. Is there a way to make it so it prints out all occurances?

CODE
function AHREF1text($string) {
return eregi_replace('\[.*URL=["|\']?([^
"\']*)["|\']?.*\]([^<]*)\[/URL\]', '<A HREF=
ONFOCUS=this.blur();></A>', $string);
}

$HTMLstring = here is linke one
PHP.net<BR> and this is link two
Nerdbrains.com<BR> and that's
that';

echo AHREF1text($HTMLstring);



kinslayer13_99@yahoo.com (Ryan) wrote in message news:<6460af62.0308121309.c83811c@posting.google.c om>...
> Greetings,
>
> I'm stumped and was hoping one of you out there can give me a hand.
>
> I found some code on php.net that changes
> <a href=http://www.somesite.com>Somesite</a>
> into
> Somesite
> Which is perfect. It handles multiple links and everything. The
> problem I'm having is trying to change it back into the links.
>
> By simple reasoning, I figured I'd just have to change a little bit of
> the working code to make it work, but it doesn't.
>
> I'm no expert, as you can probably guess, but I've been working on
> this for days now and I still can't seem to get it.
>
> Any help is much appreciated,
> Ryan
>
> Here is the code that works: (Found it at php.net)
> $website = eregi_replace('(<a [^<]*href=["|\']?([^
> "\']*)["|\']?[^>]*>([^<]*)</a>)','\\3', $website);
>
> Here is what I'm working with:
> $website = eregi_replace('\[url=("|\')?([^
> "\']*)("|\')?.*\]([^<]*)\[/URL\]', '<A HREF=\\2>\\4</A>', $website);

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:57 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0