emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#30686: closed (How to color matched region but als


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#30686: closed (How to color matched region but also show the nearby context noncolored in characters or words?)
Date: Sun, 04 Mar 2018 01:27:02 +0000

Your message dated Sat, 3 Mar 2018 18:26:28 -0700
with message-id <address@hidden>
and subject line Re: bug#30686: How to color matched region but also show the 
nearby context noncolored in characters or words?
has caused the debbugs.gnu.org bug report #30686,
regarding How to color matched region but also show the nearby context 
noncolored in characters or words?
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
30686: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=30686
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: How to color matched region but also show the nearby context noncolored in characters or words? Date: Fri, 2 Mar 2018 22:04:01 -0600
Hi,

I am looking for a feature similar to -A -B -C but not based on lines,
but based on characters or even words. Is it possible with the current
version of grep?

In the following example, I'd like to show the matched region as well
as 3 characters before and after it. But the 3 characters before and
after the match is also showed.

grep --color -o -P '.{0,3}a.{0,3}' <<< '+++++++++++++++++a++++++++++++++++++++'

-- 
Regards,
Peng



--- End Message ---
--- Begin Message --- Subject: Re: bug#30686: How to color matched region but also show the nearby context noncolored in characters or words? Date: Sat, 3 Mar 2018 18:26:28 -0700 User-agent: Mutt/1.9.3 (2018-01-21)
tags 30686 + notabug
thanks

Peng Yu wrote:
> I am looking for a feature similar to -A -B -C but not based on lines,
> but based on characters or even words. Is it possible with the current
> version of grep?
>
> In the following example, I'd like to show the matched region as well
> as 3 characters before and after it. But the 3 characters before and
> after the match is also showed.
> 
> grep --color -o -P '.{0,3}a.{0,3}' <<< 
> '+++++++++++++++++a++++++++++++++++++++'

Those three characters before and after as you say are also part of
the pattern and are also part of the match.  If you want to then only
color a subset in a second grep you can always do that.

  grep -o -P '.{0,3}a.{0,3}' <<< '+++++++++++++++++a++++++++++++++++++++' | 
grep --color 'a'
  +++a+++
     ^ only the 'a' is highlighted

Bob


--- End Message ---

reply via email to

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