grep should allow the user to color only part of the matching string.

We want to only color the contents of the id= string.
And not any other strings, and not the words id= itself.

$ cat Makefile
ids :shoufeng.html; grep -P --color=auto '(?:id=")[^"]+' $<
ids2:shoufeng.html
        perl -wlne 's/(id=")([^"]+)/$$1--$$2--/ && print;' $<|\
        grep --color=auto -e '--.*--'

If grep -P would utilize the (?:) above to exempt part of the match from
color, we wouldn't need our second weak workaround. grep (GNU grep) 3.11



Reply via email to