David Smith

David Smith

  • NA
  • 2k
  • 0

Regex help

Oct 25 2010 1:45 AM

  Ok I looking for events that begin 1 - d, and then i also want to look for  words also like apple, oranges etc.........  
I want to find rows where the string begin with 1 through D, then I also want to find rows that contain the four words below in red
 Regex r = new Regex("^[123456789ABCD]^[Apple]^[Oranges]^[Green]^[blue]");


this is the linq im doing so far

 Regex r = new Regex("^[123456789ABCD]^[Apple]^[Oranges]^[Green]^[blue]");
        var items= (from x in List.Events
                               where r.IsMatch(x.Code)
                               select new
                               {
                                 Code= x.Code,
                                 Data= x.Data
                               }).ToList();


the linq below works without the 4 red words above, but how to add the words to the regex,

Regex r = new Regex("^[123456789ABCD]");
        var items= (from x in List.Events
                               where r.IsMatch(x.Code)
                               select new
                               {
                                 Code= x.Code,
                                 Data= x.Data
                               }).ToList();

Answers (1)