Automatically link twitter usernames

by Victor

HTML

<!-- Message box -->
<p>Hey, do you know that president obama has a twitter?</p>
<p>it is @BarackObama. </p>
<p> You can also follow other related accounts like @Obama2012 @InvisibleObama also theres a email to [email protected]
<br>
Please follow me too I'm @Super_cool2013
<br>
[email protected]
<p> Normal link to a page <a href="http://google.com"> www.google.com </a></p>

CSS

.twitter{
	color: #06C;
    text-decoration: none;
    font-style: italic;
    font-weight: bold;
}

JavaScript

function linkTwitterNames(elm){
    elm.innerHTML = elm.innerHTML.replace(/\W@(\w+)/g, ' <a class="twitter" href="http://twitter.com/$1" target="_blank">@$1</a>');
}

linkTwitterNames(document.body);