tags 35077 notabug close 35077 stop On Tue, Apr 2, 2019 at 4:42 PM Todd Hoatson <todd.hoat...@gmail.com> wrote: > I tried GNU grep 2.0d, using this: *\n[^#(/]*class* > > This is intended to ensure that the word class is not preceded on the line > with #, ( or /. > > This gave me 15 matches like: > > *UpdateStatusForm.cs:62: /// A public method to get a singleton instance of > this class and display it.* > *UserViewSettingManager.cs:70: #region UserViewSettings class* > *VListControl.cs:462: message = uiFontRegex.Replace(message, "$1");* > > Why do I still get lines with (, # and / ? Is this a bug or am I doing > something wrong?
Use this instead: grep -E '^[^#(/]*\bclass\b' ... "^" is the beginning-of-line anchor The two '\b's ensure that class is not part of some other word like unclassified or classy. Also, grep-2.0d is very old. You really should get a more recent version. Latest is grep-3.3.