React.js
Angular
Ethical Hacking
Agile
AWS
BlockChain
Cassandra
Cloud
Salesforce
Scaled Agile
TOGAF
DevOps
GIT
Jenkins
Jira
Kibana
Linux
NGINX
Ansible
Artificial Intelligence
in Dot Net by

What are Regular expressions? Search a string using regular expressions?

Click here to read more about DevOps

1 Answer

0 votes
by

Regular expression is a template to match a set of input. The pattern can consist of operators, constructs or character literals. Regex is used for string parsing and replacing the character string.

For Example:

* matches the preceding character zero or more times. So, a*b regex is equivalent to b, ab, aab, aaab and so on.

Searching a string using Regex

1 static void Main(string[] args)
2 {
3 string[] languages = { "C#", "Python", "Java" };
4 foreach(string s in languages)
5 {
6 if(System.Text.RegularExpressions.Regex.IsMatch(s,"Python"))
7 {
8 Console.WriteLine("Match found");
9 }
10 }
11 }

The above example searches for “Python” against the set of inputs from the languages array. 

Related questions

Madanswer
+1 vote
asked Jun 25, 2019 in Dot Net by Venkatshastri
+1 vote
+1 vote
asked Jun 25, 2019 in Dot Net by Venkatshastri
...