Question

I am trying to do a search and replace in eclipse on the imports in my java file but I cant get the search to match the imports I want.

In short I want to match all import statements except ones that end with a particular string.

so far I have ^import\s.*[^{STRINGTEXT}];$

but this does not return the results I need. I have tried using related expressions from other questions on this site but none seem to work...I would guess that this is a special case. Any help would be appreciated

Was it helpful?

Solution

With a small lookbehind you can do it easily

^import.*?(?<!BADSTRING);$

It match import then all chars up to ;, checking that ; not preceded by BADSTRING

OTHER TIPS

This one should work:

import .*(?!StoreModelTestCase){1};$

But I think it is not a really good idea, because, you can also use full qualified classnames within the source later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top