Q:

What do you understand by regular expressions in C#? Write a program that searches a string using regular expressions

0

What do you understand by regular expressions in C#? Write a program that searches a string using regular expressions

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

A regular expression is a template for matching a set of input. It can consist of constructs, character literals, and operators. Regex is used for string parsing, as well as replacing the character string. Following code searches a string “C#” against the set of inputs from the languages array using Regex:

static void Main(strong[] args)
{
    string[] languages = {“C#”, “Python”, “Java”};
    foreach(string s in languages)
    {
        if(System.Text.RegularExpressions.Regex.IsMatch(s,“C#”))
        {
            Console.WriteLine(“Match found”);
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# Interview Questions and Answers,You Need To Know

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What is the difference between ref & out parameter... >>
<< Why Doesn’t C# Allow Static Methods to Implement...