Grep_Buffer fix
Submitted by Friday, 2 March, 2012 - 17:27
on
Not sure what the correct method for suggesting an update, but I just fixed grep_buffer on my box and thought I would share:
import java.util.regex.*;
Pattern p = null;
Matcher m = null;
String regexp = Macros.input(view, "Regular Expression");
public static final String SEP = " - ";
public static final String LF = "\n";
if(regexp == null) {
return;
} try {
p = Pattern.compile(regexp);
} catch(REException e) {
Macros.error(view, "Invalid regular expression");
return;
}
StringBuffer buf = new StringBuffer();
for(int i = 0; i < textArea.getLineCount(); i++) {
String line = textArea.getLineText(i);
m = p.matcher(line);
if (m.find()) {
buf.append(i).append(SEP).append(line).append(LF);
}
}
import java.util.regex.*;
Pattern p = null;
Matcher m = null;
String regexp = Macros.input(view, "Regular Expression");
public static final String SEP = " - ";
public static final String LF = "\n";
if(regexp == null) {
return;
} try {
p = Pattern.compile(regexp);
} catch(REException e) {
Macros.error(view, "Invalid regular expression");
return;
}
StringBuffer buf = new StringBuffer();
for(int i = 0; i < textArea.getLineCount(); i++) {
String line = textArea.getLineText(i);
m = p.matcher(line);
if (m.find()) {
buf.append(i).append(SEP).append(line).append(LF);
}
}