Reputation: 1185
I would like to find all occurrences of the below pattern.
import com.pack1.pack2.blah1.className1 ;
import com.pack1.pack2.blah2.className2 ;
import com.pack1.DifferentPackage.blah3.className3 ;
I want to find all import statements which will match the third line.
Something like below
import com.pack1.!(pack2).*
I tried a few examples from tutorials - but couldn't achieve the objective.
Upvotes: 1
Views: 226
Reputation: 70732
You are looking for a Negative Lookahead here.
import com\.pack1\.(?!pack2\b).*
The word boundary \b
asserts that on one side there is a word character, and on the other side there is not. Also since you state you are looking for lines, you may want to add beginning of string ^
and end of string $
anchors.
^import com\.pack1\.(?!pack2\b).*$
Upvotes: 4