I am currently writing a program that will check a line from a file and see if a US state is contained in that line and that it is also spelled correctly. I have it currently working for a single state. I would like to be able to see if any of all the US states are in the line.
This is my code so far below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
var r = new Regex(@"\bArizona\b", RegexOptions.IgnoreCase);
string[] lines = File.ReadAllLines(@"C:\sampledata.dat");
foreach (string s in lines)
{
var m = r.Match(s);
Console.WriteLine(m.Success); // false
Console.WriteLine(s);
Console.ReadLine();
}
}
}
}
Essentially I would like to do something like
var r = new Regex(@"\bAll US States.txt\b", RegexOptions.IgnoreCase);