In the eclipse workspace search (CTRL+H) what regular expression could be used to find occurrences of a word that do not begin with 2 leading forward slashes (/) – or in other words, are not commented?
For example //var_dump and // var_dump is what is not to be matched, but var_dump is what is to be matched.
The following regex in the file search tab would do it:
If you only care about the first word on a line, precede it with a caret:
The
(?<!//)part is a negative lookbehind – it only matches thing that do not have the contents of the brackets before the thing you are looking for.However, if you are looking for variables that are not commented rather than not preceded by the specific combo “//”, you might be better off using a syntax-aware search, which depends on the language used. For example, this regex will still match
/* var_dump */, which you may or may not want to happen. A syntax-aware search would know this is commented.If you look in the Search window, you will see a “Java Search” tab and tabs for other plugins you might have (I have “C/C++ Search” and “Git Search” for example). In these tabs, you can choose to search only for functions, variable, classes, or whatever else makes sense in that language.
A further thing you might want is to hit Ctrl–Shift–G on a word and it will list all the references to this object in your code – very useful when trying to track down what is calling your function or using your variable.