Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

Shorten YouTube Link

Description
This macro shortens a YouTube video from the full https://www.youtube.com/watch?v= to the youtu.be version.
Language
C#.net
Minimum Version
Created By
Joshua T
Contributors
-
Date Created
Jan 4, 2017
Date Last Modified
Jan 4, 2017

Macro Code

using System;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        Regex youtubeRegex = new Regex(@"https://www\.youtube\.com\/watch\?v\=(?<id>[^\&]*)(?:\&.*)?");
        Match match = youtubeRegex.Match(text);

        if (!match.Success) {
            // If this isn't a YouTube video, don't do anything to it
            return text;
        }

        Group idGroup = match.Groups["id"];
        string idText = idGroup.Value;
        return "https://youtu.be/" + idText;
    }
}