|
Posted by Philip Hallstrom on 04/29/05 04:58
I'm just lazy... and this is easier than changing them all by hand :)
http://www.oreilly.com/catalog/regex/
I've skimmed parts of it... makes my head hurt :)
On Thu, 28 Apr 2005, php wrote:
> Thanks SOO much.
>
> It works flawlessly. I find it scary that there are people out there who do
> regular expressions off the top of their heads. Anyway, thanks alot,
>
> -Ethan Nelson,
> Modulus, LLC
>
> "Philip Hallstrom" <php@philip.pjkh.com> wrote in message
> news:20050428134450.D87918@wolf.pjkh.com...
>>
>> On Thu, 28 Apr 2005, php wrote:
>>
>>> Its a long story, but basically, theres some code we cannot get around
>>> that
>>> is taking anchor tags such as <a href="#sat"> and turning them into <a
>>> href="http://host.com/folder/file.html?var=var&var2=var2#sat>.
>>>
>>> I need to undo this action with a pattern match on a large body of
>>> content
>>> with "". Can this be done. Here are further details:
>>>
>>> I need a regular expression that will recognize the following where
>>> #anchor
>>> can be anything such as #sat or #sunday or #lastpage:
>>>
>>> <a*href="http://*#anchor"*>
>>>
>>> And turn it into this:
>>>
>>> <a*href="#anchor"*>
>>>
>>> What I am doing is removing the
>>> http://host/.../.../file.html?variable&variable that immediately precedes
>>> the #anchor.
>>
>> Hmm...
>>
>> $str = ereg_replace('<(a[^>]*href=")http://[^#]*(#[^"]*")>', '<$1$2>',
>> $str);
>>
>> Completely untested and assumes lowercase tags and the use of double
>> quotes and that a single <a href> tag fits on a single line...
>>
>> But it's a start.
>>
>> -philip
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
[Back to original message]
|