How to

search text using regular expressions

Published: 24. October 2011 | Updated: 26. October 2011
License: Microsoft Public License (MS-PL)
Categories: Framework » Regex
Tags: C# Regex Text
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Text.RegularExpressions;

Code

string input = "+ 00444666777 abc";
string pattern = "[0-9]+";
Match match = Regex.Match(input, pattern);

if(match.Success)
{
    string result = match.Value;
    Console.WriteLine(result);
}
Console Output:
00444666777
Send us feedback about this snippet »



Related Snippets: