Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SMS recipient filter testing
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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); } } } }
Show compiler warnings
[
+
]
Show input
Compilation time: 0.16 sec, absolute running time: 0.2 sec, cpu time: 0.19 sec, average memory usage: 16 Mb, average nr of threads: 4
edit mode
|
history
|
discussion
Restrict = true 48995764 97063710 01234567