Re: [PHP-DB] - ereg_replace

2003-11-14 Thread David T-G
Hi!

...and then ÍÉÊÏÓ ÃÁÔÓÇÓ said...
% 
...
%  ereg_replace(^a href=\([:alnum:])\$, a href=\\\1\
% target=\_blank\, $string)
% 
%  I echo the result but nothing changing.
%  What Im doing wrong?

Is your string really the only thing on a line, or could it be anywhere
in the input?  The ^ (beginning) and $ (ending) anchors are probably
messing you up.

If your format *is* like this, you could do a quick

  preg_replace('/$/',' target=_blank',$string)

(untested) and be done with it :-)


%  Thanx


HTH  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP-DB] - ereg_replace

2003-11-14 Thread
Thank you for reply, but the a is not the only tag in my string.

...
%  ereg_replace(^a href=\([:alnum:])\$, a href=\\\1\
% target=\_blank\, $string)
% 
%  I echo the result but nothing changing.
%  What Im doing wrong?

Is your string really the only thing on a line, or could it be anywhere
in the input?  The ^ (beginning) and $ (ending) anchors are probably
messing you up.

If your format *is* like this, you could do a quick

  preg_replace('/$/',' target=_blank',$string)

(untested) and be done with it :-)


%  Thanx

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



Re: [PHP-DB] - ereg_replace

2003-11-14 Thread David T-G
Hi again!

...and then ÍÉÊÏÓ ÃÁÔÓÇÓ said...
% 
% Thank you for reply, but the a is not the only tag in my string.

You're quite welcome, and now we definitely know that ^ and $ are not
what you need.


HTH  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP-DB] - ereg_replace

2003-11-14 Thread John W. Holmes
  wrote:

 I'm trying to replace the string say a href=http://www.mysite.gr;
 with a href=http://www.mysite.gr target=_blank with no luck
 I use the code:

 ereg_replace(^a href=\([:alnum:])\$, a href=\\\1\
target=\_blank\, $string)
Since it looks like you're changing all of the links, how about a simple 
str_replace() replacing 'a' with 'a target=_blank' ??

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals - www.phparch.com

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


Re: [PHP-DB] - ereg_replace -SOLVED

2003-11-14 Thread
Thank you all for the replies.
I solve it with the following code:

eregi_replace(a href=\(.+)\, a href=\\\1\ target=\_blank\
class=\down_txt\, $body);


- Original Message - 
From: John W. Holmes [EMAIL PROTECTED]
To:   [EMAIL PROTECTED]
Cc: PHP-mailist [EMAIL PROTECTED]
Sent: Friday, November 14, 2003 3:25 PM
Subject: Re: [PHP-DB] - ereg_replace


   wrote:

   I'm trying to replace the string say a href=http://www.mysite.gr;
   with a href=http://www.mysite.gr target=_blank with no luck
 
   I use the code:
 
   ereg_replace(^a href=\([:alnum:])\$, a href=\\\1\
  target=\_blank\, $string)

 Since it looks like you're changing all of the links, how about a simple
 str_replace() replacing 'a' with 'a target=_blank' ??

 -- 
 ---John Holmes...

 Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

 php|architect: The Magazine for PHP Professionals - www.phparch.com

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


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



Re: [PHP-DB] - ereg_replace -SOLVED

2003-11-14 Thread CPT John W. Holmes
From:   [EMAIL PROTECTED]

 eregi_replace(a href=\(.+)\, a href=\\\1\ target=\_blank\
 class=\down_txt\, $body);

How is that any different than just doing a str_replace() on a, though?
The str_replace() is going to be much faster than the eregi_replace()
function and href doesn't _have_ to be the first attribute in the anchor
tag...

Just trying to open your mind to other possibilities... :)

---John Holmes...

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



Re: [PHP-DB] ereg_replace

2003-09-30 Thread CPT John W. Holmes
From: Dillon, John [EMAIL PROTECTED]

 strip_tags() is used to remove HTML tags, eg for showing text on the
browser
 and then sending it by plain text email or storing in the db.  As a matter
 of interest, how is this done using ereg_replace.  I thought this would
work
 ^.*$, that is being with  and any number of single characters ending
with
 .  Didn't seem to work - why?

Because you have ^ and $ (beginning of string and end of string), you're
saying the entire string must be between  and  in order for a match to
occur.

Take them out and make sure you're not being greedy, i.e. this tag and
that tag are left being reduced to this  are left.

ereg_replace('[^]*','',$string);

or

preg_replace('/[^]*/','',$string);

should work.

---John Holmes...

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