Skip to content

Instantly share code, notes, and snippets.

@jacyzon
Created June 22, 2014 09:56
Show Gist options
  • Select an option

  • Save jacyzon/321bc67b448cf7d36fc0 to your computer and use it in GitHub Desktop.

Select an option

Save jacyzon/321bc67b448cf7d36fc0 to your computer and use it in GitHub Desktop.
Regular expression capturing MQTT device ID
using System;
using System.Text;
using System.Text.RegularExpressions;
class RegularEx
{
static void Main(string[] args)
{
string pattern = @"(?<=^mqtt-subscription-).+(?=qos1$)";
Regex regex = new Regex(pattern);
Match match = regex.Match("mqtt-subscription-TEST-BLAqos1");
Console.WriteLine(match);
Console.Read();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment