DCSIMG
LINQ To Regex - Zuker On Foundations

Zuker On Foundations

The realm of .NET (WPF, WCF and all around)
LINQ To Regex

Via this post by Roy Osherove.

A nice approach for working against regular expressions.
I must admit, it looks as if it would take some time to master and love.

Nice to know it's out there :)

  [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);

            }

        }

Published Thursday, January 15, 2009 3:24 PM by Amir Zuker

תגים:,

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: