SpawnPoint

My Blog

Hello

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!


Comments »

Atrus @ 2007-09-02 02:24:43
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 @ 2007-09-01 21:43:42
In english please! :-S *omg so confusing*

Wayetender's Profile Image
  • Wayetender

    Code & Development Team
  • Member Since:2007-05-24 16:11:00
  • Last Online:2008-10-04 17:47:08

SpawnPoint Info

Blog Stats:

  • Total Blogs: 18
  • Popular Blogs: 17

My Games

World of Warcraft [PC]

World of Warcraft [PC]

Four years have passed since the aftermath of Warcraft III: Reign of Chaos, and a great tension now ...

SpawnPoint: Game File Community featuring PC Video Gaming, Free PC Games, Counter-Strike, Action And Strategy Files, Game Forums and Game News