using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
public class Test
{
public static void Main()
{
var strings = new List<string> { "1 abcd", "abcd 1", "1 abcd 1"};
var pattern = "(^)?abcd(?(1)|$)";
foreach (var s in strings)
{
Console.WriteLine("{0} => {1}", s, Regex.IsMatch(s, pattern));
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLklPOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLlRleHQuUmVndWxhckV4cHJlc3Npb25zOwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCXZhciBzdHJpbmdzID0gbmV3IExpc3Q8c3RyaW5nPiB7ICIxIGFiY2QiLCAiYWJjZCAxIiwgIjEgYWJjZCAxIn07CgkJdmFyIHBhdHRlcm4gPSAiKF4pP2FiY2QoPygxKXwkKSI7CiAgICAgICAgZm9yZWFjaCAodmFyIHMgaW4gc3RyaW5ncykKICAgICAgICB7CiAgICAgICAgCUNvbnNvbGUuV3JpdGVMaW5lKCJ7MH0gPT4gezF9IiwgcywgUmVnZXguSXNNYXRjaChzLCBwYXR0ZXJuKSk7CiAgICAgICAgfQoJfQp9