Hi,
I am trying to write a pattern in Java to match against Java import declarations.
Example:
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.InputFormat;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
// import org.apache.hadoop.mapreduce.Something;
/* import org.apache.hadoop.something.else; */
Would match with only:
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.InputFormat;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
So far I have the following regex:
"[^A-Za-z0-9\\n]? *import(static|\\s)+[\\w.]*(\\*)?(\\s)*;"
But it's not working. For example:
import org.junit.Test;
import java.util.ArrayList;
/* The import name; lazily initialized; defaults to a unspecified,...
returns:
import org.junit.Test;
import java.util.ArrayList;
import name;
which is wrong.