linux - java string regex head not contains -
i have string :
[root@slave1 ~]# test -d /root/workspace/servers || echo not found [root@slave1 ~]# test -d /root/workspace/servers || echo not found not found [root@slave1 ~]# test -d /root/workspace/servers || echo not found [root@slave1 ~]# test -d desktp || echo not found not found
and want find word not found
without echo
@ first
as can see , in string , there 2 match
how can ??
use negative lookbehind.
"(?<!\\becho )not found(?=\\s|$)"
you use same regex in grep.
grep -op '(?<!\becho )not found(?=\s|$)' file
(?<!\becho )
- don't lookafter echo<space>
not found(?=\s|$)
- match not found
strings must followed space or line end.
Comments
Post a Comment