I'm looking for a way to split a Twitter permalink string on its final forward slash, so I can store the tweet_id. Two examples:
http://twitter.com/bloombergnews/status/55231572781170688
http://twitter.com/cnn/status/55231572781170688
Each URL has a similar format:
http://twitter.com/<screen_name>/status/<id_str>
With what regular expression would I easily capture every time?
This is not a job for regular expressions, IMHO.
I would do this:
$parts = explode('/', rtrim($url, '/'));
$id_str = array_pop($parts);
REGX ? yes; simple one liner.
$url = 'http://twitter.com/bloombergnews/status/55231572781170688';
Perl
($f1 = $url) =~ s/^.*\///;
print $f1;
PHP
$f1 = preg_replace("/^.*\//","",$url);
echo $f1;
EDIT: backslashes didn't show; fixed in edit box by double \\ (wierd!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With