grep -P '(?!.*//)word' i learnt to exclude a pattern in grep using grep -P with perl regex. but i don't know how to exclude //
i tried
/\/\\/
nothing seems to work
grep -P '(?!.*//)word' i learnt to exclude a pattern in grep using grep -P with perl regex. but i don't know how to exclude //
i tried
/\/\\/nothing seems to work
Use
grep -P '^\s*//.*(*SKIP)(*F)|word' file
See regex proof
EXPLANATION
--------------------------------------------------------------------------------
^ the beginning of the string
--------------------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
--------------------------------------------------------------------------------
// '//'
--------------------------------------------------------------------------------
.* any character except \n (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
(*SKIP)(*F) skip and proceed searching for the next pattern
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
word 'word'