Wayetender

Member

Blog Archive

Blog

Hello 2 Comments

Well I am now finally all moved into college. It's the same place the iPhone unlocker is going to. There haven't been as many updates recently just because I've been slightly busy. The good news is that league planning and development has been green-lighted. But Where's Clans??? They're on their way. Just need testing and tweaking and what-not. Unfortunately I am not paid to twiddle my thumbs. Although I am paid to tap on the keyboard.

Anyhow, I leave you with one last nice little snippet of code. Have you ever wanted to generate links (a tags) in user input? Ever just give up when you realize that there might be HTML input in there as well, and your simple attempt fails when someone does something like: <a href="http://www.google.com">http://www.google.com</a> and your link generator ends up creating: <a href="<a href="http://www.google.com">http://www.google.com</a>"><a href="http://www.google.com">http://www.google.com</a></a>. Well, fear not, with a bit of advanced regular expressions, I came up with this solution:
function Linkify($input) { return preg_replace('/ (http:\/\/|[^\/]www\.)([a-z0-9]+[a-z0-9\._%,#&-;?\/:]+)(?!<)/i', '<a href="http://\\2" rel="nofollow" target="_blank">\\1\\2</a>', ' ' . $input); }


Anyhow enjoy!

Posted in   Development
2007-09-01 20:37:00 | 539 Views

Comments

Atrus at Sep 2, 2007.

You never cease to amaze, Lucas. I can't wait to see the body of work on Clans, and what's to come with the league. Best of luck with college.

Alpha23 at Sep 1, 2007.

In english please! :-S *omg so confusing*

Leave a Comment

You must be logged in to comment