Using RegEx
Written by: maffelu , 2009-04-16 18:00:43
using System.Text.RegularExpressions;
using System;
using System.Text.RegularExpressions;
namespace regexp
{
class Program
{
public static void Main(string[] args)
{
//Our strings
string[] strArr = new string[3];
strArr[0] = "There is no more bear!";
strArr[1] = "There is no more beer!";
strArr[2] = "There is not more beor?";
//Our pattern
string pattern = "be[ea]r";
//Our loop ;)
for (int i = 0;i <= 2 ;i++ ) {
if (Regex.IsMatch(strArr[italic], pattern))
{
Console.WriteLine("beer was found!!!");
}
else
{
Console.WriteLine("beer was NOT found...");
}
}
Console.Read();
}
}
}
There are no comments on this article.
If you have any question or just want to leave a message, just fill out the form below!
Your e-mail will not be visible in your post, it is for validation reasons only
Maffelu
Creator and admin of MorkaLork.com.
Started programming in HTML back when frames and tables was the way to design a page, moved on to Pascal/Delphi, PHP, javascript/jQuery, VB.NET/C#, Java and C++.
Currently studies .NET (in general) focusing on ASP.NET.