using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?P<NUMBER>[+-]?[0-9]+\.[0-9]+|-?\+?[\d]+)|(?P<LPAR>\()|(?P<RPAR>\))|(?P<NAME>%?\w\w*\-?>?\w*\!?\??\.? |[\+\-\.]+?)|(?P<BOOL>#t|#f|true|false)|(?P<STRING>^\""[\w].*[\w]*\"")|(?P<CHAR>[#|\\a|\b|\\Backspace]+)|(?P<COMMENT>[;;].*$)|(?P<QUOTES>\'+|\""+)|(?P<OP>[\?==|<=|=|>=\-+*/<>])|(?P<IGNORE>[\s\t])";
string input = @";; Retorna a sequência de Collatz para o número dado
;; Argumento deve ser um número inteiro.
x ;; comentário
:defn collatz n:
:if [n = 1] then:
'(+ 1 2)
#t
#f
true
false
""dsfsfsf-dfjsif""
-12.34
""(das)"" ' '
#
#
\a #\Backspace
(list 1)
:elif (even? n) then:
(cons n (collatz [n quotient 2]))
:else:
(cons n (collatz [[3 * n] + 1]))
;; Imprime a sequência de Collatz de 42";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx