我有类似下面的内容,需要提取“+”和行尾之间的所有文字。
+ context: projectRoot,
+ entry: path.resolve(projectRoot, 'src/scripts/Index'),
+
+ resolve: {
+ extensions: ['', '.js', '.jsx'],
+ };
module: {
+ loaders: [{
+ test: /\.jsx?$/,
+ exclude: /node_modules/,
+ loader: 'babel?presets[]=stage-0,presets[]=react,presets[]=es2015',
},
+
+ output: {
+ path: config.build.assetsRoot,
+ publicPath: deploymentBuild ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
+ filename: '[name].js',
+ },
我想从“+”开始提取每一行,并忽略其他行。
帮助将不胜感激。 感谢。
编辑:2
String codeDiff = "";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DiffFormatter df = new DiffFormatter(baos);
df.setRepository(git.getRepository()); // get repo
List<String> diffCodes = new ArrayList<>();
List<String> packageChangesArray = new ArrayList<>(); // plus and minus changes from package json
for (DiffEntry entry : diffs) { //loop
df.format(df.toFileHeader(entry));
diffCodes.add(new String(baos.toByteArray()));
codeDiff = new String(baos.toByteArray());
Pattern p = Pattern.compile("(\\+)(.*)(,)" ,Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
Matcher m = p.matcher(codeDiff);
while (m.find()){
String c1=m.group(1);
// String c2=m.group(2);
System.out.print("("+c1.toString()+")"+"("+")"+"\n");
}
}