using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"\b\d+(?:,\d+)*";
string input = @"this is number 88 and rest of the text
this is number 2,563 and rest of the text
after I export it into excel. Problem is that I'm using custom tool (not programming language ) that excepts text as an input, regex pattern and export the output. This is why I need single pattern that eliminate space and produce either 88 or 2563 or any other number. The commas are every 3 positions obviously, so it can also be 1,345,321 as well as just single number 5 between ""this is number .... and rest of the text""";
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