[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35077: grep bug?

From: Jim Meyering
Subject: bug#35077: grep bug?
Date: Sun, 5 May 2019 16:06:18 -1000

tags 35077 notabug
close 35077

On Tue, Apr 2, 2019 at 4:42 PM Todd Hoatson <address@hidden> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]