Home All Groups Group Topic Archive Search About
Author
2 Apr 2007 5:24 PM
Dave E
I am trying to build a regular expression that will fail to match if the line
starts with a particular phrase, for example I want the match to fail if the
line starts with "To Do".  In other versions of regular expressions there is
the ~ operator that lets me specify this, so I could do something like ~To
Do.* and then it will not match any lines that have To Do in them.  How do I
create something similar in .NET?

Thanks,

--
Dave E

Author
2 Apr 2007 5:47 PM
sloan
Good book ( and examples ) here:
http://www.apress.com/book/supplementDownload.html?bID=446&sID=2793




Show quote
"Dave E" <Da***@discussions.microsoft.com> wrote in message
news:52266FE7-11DF-4E03-A17A-D4390732E1F3@microsoft.com...
> I am trying to build a regular expression that will fail to match if the
line
> starts with a particular phrase, for example I want the match to fail if
the
> line starts with "To Do".  In other versions of regular expressions there
is
> the ~ operator that lets me specify this, so I could do something like ~To
> Do.* and then it will not match any lines that have To Do in them.  How do
I
> create something similar in .NET?
>
> Thanks,
>
> --
> Dave E
Author
2 Apr 2007 6:00 PM
Kris Erickson
Dave E wrote:
> I am trying to build a regular expression that will fail to match if the line
> starts with a particular phrase, for example I want the match to fail if the
> line starts with "To Do".  In other versions of regular expressions there is
> the ~ operator that lets me specify this, so I could do something like ~To
> Do.* and then it will not match any lines that have To Do in them.  How do I
> create something similar in .NET?
>
> Thanks,
>

^(?!To Do).*

Will match all lines not starting in To Do...  If you want all lines not
starting in To Do or Fix Me

^(?!To Do|Fix Me).*

Set your own options for case insensitive, etc, but it must be set to
multiline for this to work.

Kris
Author
2 Apr 2007 7:38 PM
Dave E
Thanks a lot.  That worked great!
--
Dave E


Show quote
"Kris Erickson" wrote:

> Dave E wrote:
> > I am trying to build a regular expression that will fail to match if the line
> > starts with a particular phrase, for example I want the match to fail if the
> > line starts with "To Do".  In other versions of regular expressions there is
> > the ~ operator that lets me specify this, so I could do something like ~To
> > Do.* and then it will not match any lines that have To Do in them.  How do I
> > create something similar in .NET?
> >
> > Thanks,
> >
>
> ^(?!To Do).*
>
> Will match all lines not starting in To Do...  If you want all lines not
> starting in To Do or Fix Me
>
> ^(?!To Do|Fix Me).*
>
> Set your own options for case insensitive, etc, but it must be set to
> multiline for this to work.
>
> Kris
>

AddThis Social Bookmark Button