You are here: Re: help with regex « PHP Programming Language « IT news, forums, messages
Re: help with regex

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация