Amit Dhamu

Writes Code

Convert Twitter Links To URLs

# Anchor Tags
$tweet = preg_replace("@(https?://([-w.]+)+(:d+)?(/([w/_.]*(?S+)?)?)?)@", "<a href="$1">$1</a>", $tweet);

# @ Replies
$tweet = preg_replace("/@([0-9a-zA-Z]+)/",  "<a href="http://twitter.com/$1">@$1</a>", $tweet);

# Hash Tags
$tweet = preg_replace("/#([0-9a-zA-Z]+)/", "<a href="http://twitter.com/search?q=$1">#$1</a>", $tweet);


twitter / hashtag / @reply / regex / php / regular expressions

← Smooth Slide Toggle 301 Redirect →