clipped from: weblogs.asp.net   

Introducing LINQ To Regex


  [Test]

        public void FindEmailUsingPattern()

        {

            var query = from match in

               RegexQuery.Against("sdlfjsfl43r3490r98*(*Email@somewhere.com_dakj3j")

                        where match.Word.Repeat.AtLeast(1)

                            .Literal("@")

                            .Word.Repeat.AtLeast(1)

                            .Literal(".")

                            .Choice.Either(

                                 Pattern.With.Literal("com"),

                                 Pattern.With.Literal("net"))

                            .IsTrue()

                        select match;

            foreach (var match in query)

            {

                Assert.AreEqual("Email@somewhere.com",match.Value);

            }

        }