|
Posted by Petra Meier on 03/07/07 09:03
noone has an idea? :(
On Mar 5, 4:57 pm, "Petra Meier" <mord...@sms.at> wrote:
> Hello,
>
> I use the following script to parse URI and email:
>
> function parseLinks($sData){
> $regexEmail = "/\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-
> Za-
> z0-9]+)*\.[A-Za-z0-9]+/";
> $sData = preg_replace($regexEmail, "<a id='external'
> href='mailto:'$0'>$0</a>", $sData);
> $regexURI = '#(^|[^\"=]{1})(http://|ftp://|https://|news:)([^
> \s<>]+)
> ([\s\n<>]|$)#sm';
> $sData = preg_replace($regexURI, "\\1<a id=\"external\" name=
> \"\\2\
> \3\">\\2\\3</a>\\4", $sData);
> return $sData;
>
> }
>
> it works just fine, unfortunately I parse the links from texts where I
> have fullstops, commas, colons and semicolos at the end of URI which
> are parsed as part of the URI:
>
> A sentence with a linkhttp://uri.in.senctence.com/foo.html, and a
> comma after the link
>
> would be parsed to:
>
> A sentence with a link <a href="http://uri.in.senctence.com/
> foo.html,">http://uri.in.senctence.com/foo.html,<a/> and a comma after
> the link
>
> I want to have it like this though:
>
> A sentence with a link <a href="http://uri.in.senctence.com/
> foo.html">http://uri.in.senctence.com/foo.html<a/>, and a comma after
> the link
>
> I already invested a lot of time with these regex and didn't succeed.
> Any of you regex-gurus could help me please! :)
>
> Petra Meier
Navigation:
[Reply to this message]
|