Re: Re: Removing link on the fly, but leave link text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Aug 31, 2010, at 16:26, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx> wrote:

> On Tue, 2010-08-31 at 17:15 -0300, Jo?o C?ndido de Souza Neto wrote:
> 
>> Theres an eror.
>> 
>> The correct is:
>> 
>> $pattern = array(
>>    "/<a [^>]>/",
>>    "/</a>/"
>> );
>> 
>> $text =  preg_replace($pattern, "", $text);
>> 
>> 
>> -- 
>> Joo Cndido de Souza Neto
>> 
>> ""Joo Cndido de Souza Neto"" <joao@xxxxxxxxxxxxxxxxxxx> escreveu na 
>> mensagem news:D0.73.48953.EE16D7C4@xxxxxxxxxxxxxxx
>>> Try this:
>>> 
>>> $pattern = array(
>>>   "/<a [^>]/",
>>>   "/</a>/"
>>> );
>>> 
>>> preg_replace($pattern, "", $text);
>>> 
>>> -- 
>>> Joo Cndido de Souza Neto
>>> 
>>> "Karl DeSaulniers" <karl@xxxxxxxxxxxxxxx> escreveu na mensagem 
>>> news:007BC8E1-B2C8-4DD5-9D18-EB07B0D55C0E@xxxxxxxxxxxxxxxxxx
>>>> Hi,
>>>> Say I have some text.
>>>> 
>>>> $text = 'You can logon here: <a href="http://website.com/shop/
>>>> index.php?username='.$username.'">http://website.com/shop/index.php?
>>>> username='.$username.'</a>. This link will take you to your web
>>>> browser to login.'.$eol;
>>>> 
>>>> I want to be able to strip the "<a href="http://website.com/shop/
>>>> index.php?username='.$username.'">" and </a>.
>>>> Leaving just the http://website.com/shop/index.php?username='.
>>>> $username.' text, so it would end up like.
>>>> 
>>>> 
>>>> $text = 'You can logon here: http://website.com/shop/index.php?
>>>> username='.$username.'. This link will take you to your web browser
>>>> to login.'.$eol;
>>>> 
>>>> I have tried MANY different ways and have no success.
>>>> Can anyone help me?
>>>> TIA
>>>> 
>>>> 
>>>> Karl DeSaulniers
>>>> Design Drumm
>>>> http://designdrumm.com
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
>> 
> 
> 
> Regular expressions are evil when used like this. Consider the following
> valid HTML:
> 
> <a href="math_operators.php" title="The > Operator">The &gt;
> Operator</a>
> 
> The HTML is perfectly valid, but the regex will break because it "see's"
> the end of the tag prematurely from the > inside the title attribute
> value.
> 
> However, if the HTML is going to be a very small subset in which you
> will always know this sort of thing won't happen, then you could use the
> regex.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 

Karl,

Is this for an email?

Bastien

Sent from my iPod

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux