Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SMS recipient filter testing
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { private static readonly Regex configValueExtrator = new Regex(@"(?:restrict=)(true|false)\|?(?:recipients=)(?:,?(\+?\d{8,10}))*"); private static readonly string config = "restrict=true|recipients=48995764,97063710,01234567"; public static void Main(string[] args) { ParseConfigString(config); Console.WriteLine("Restrict = {0}", Restrict ? "true" : "false"); foreach(var recipient in ValidRecipients){ Console.WriteLine(recipient); } } private static bool _restrict = true; public static bool Restrict { get{ return _restrict;} private set { _restrict = value; } } private static List<string> _validRecipients = new List<string>(); public static IEnumerable<string> ValidRecipients { get { return _validRecipients; } private set { _validRecipients = value.ToList(); } } public static void ParseConfigString(string config) { var matches = configValueExtrator.Matches(config); if (matches.Count < 1) { return; } var match = matches[0]; if (match.Groups.Count < 3) { return; } _restrict = !match.Groups[1].Value.Equals("false"); foreach (Capture capture in match.Groups[2].Captures) { _validRecipients.Add(capture.Value); } } } }
run
|
edit
|
history
|
help
0
Main3-3
binary search tree reversal
My quad calc
smallestof3
Today's work
User
Prime number
Singly-linked IList<T> in C#
ProtectedUse
EFDCSX ASXS