Regex question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 said:
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
 
Thanks a lot. That worked great!
--
Dave E


Kris Erickson said:
^(?!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
 
Back
Top