scriptNode

Web development with a focus on JavaScript RSS

Making @Twitter Names Clickable

Novice Matt Hackett Published August 30th, 2009 by Matt Hackett

Here's a super quick Script Sunday for you: making @Twitter usernames clickable. Here's an example:

@scriptnode

Should be:

@<href="http://twitter.com/scriptnode">scriptnode</a>

Which looks like:

@scriptnode

And here's how to do it in PHP and JavaScript:

PHP

That was easy! Now let's get to the more interesting JavaScript, which allows us to test inline!

JavaScript

You can run this code right here:

Some @test code

I'm awful at regular expressions; please do let me know if I could optimize somewhere or if I missed something. Edit: + instead of *

Read other articles tagged: , , , ,

Comments (2)

Thoughts?

(required)

(not shared)

© 2010 scriptNode