|
Posted by Kimmo Laine on 09/12/06 10:11
"Ac1d^" <adam82s@gmail.com> wrote in message
news:1158054059.855759.172420@i42g2000cwa.googlegroups.com...
> gehegeradeaus@gmail.com napisal(a):
>> Can someone help me to make a regular expression for this sort of
>> replacement :
>>
>> text with {link:pagehref}a link{/link}.
>>
>> replace to ->
>>
>> text with <a href="pagehref">a link</a>
>>
>> I tried several things but nothing seems to work... e.g.
>>
>> $value=preg_replace("/\{link\:(.+?)\}(.+?)\{\/link\}/s","<a href=\"$1\"
>> target=\"_blank\">$2</a>",$value);
>>
>> Thanks in advance!
>
> Try this pattern.
> "/\{link\:(.*)\}(.*)\{\/link\}\s/"
> rest of the code looks fine.
The problem is that {link:(.*)} matches to the entire "{link:pagehref}a
link{/link}", it reaches the last occurance of } untill stops. Instead of .*
the pattern should be (^})* ie. match anything but }, then it should stop at
the first } which closes the {link} pseudotag.
something like:
"/\{link\:((^})*)\}(^{*)\{\/link\}\s/"
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net || Gedoon-S @ IRCnet || rot13(xvzzb@bhgbyrzcv.arg)
Navigation:
[Reply to this message]
|