Jan 4, 2018

Regex to get the Twitter Tweet Id from a status embed link

This regex will grab the tweet id from a Twitter embed url with some example C# code.

var regex = new Regex(@"twitter\.com\/.*\/status(?:es)?\/([^\/\?]+)", RegexOptions.IgnoreCase);
var match = regex.Match(href);
if (match.Success) {
    return match.Groups[1].Value;

Tags: regex

No Comments

Add a Comment