How to use Regex pattern to check if there is one or more digits in a string with C#

1 Answer

0 votes
using System;
using System.Text.RegularExpressions;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Regex regex = new Regex(@"\d+");

            Match match = regex.Match("c c++ 987 c# java");

            if (match.Success) {
                Console.WriteLine(match.Value);
            }
        }
    }
}


/*
run:
      
987
  
*/

 



answered Aug 5, 2018 by avibootz
...