use of java.util.regex.Pattern in project AndResGuard by shwenzhang.
the class Configuration method addToCompressPatterns.
private void addToCompressPatterns(String value) throws IOException {
if (value.length() == 0) {
throw new IOException(String.format("Invalid config file: Missing required attribute %s\n", ATTR_VALUE));
}
value = Utils.convetToPatternString(value);
Pattern pattern = Pattern.compile(value);
mCompressPatterns.add(pattern);
}
use of java.util.regex.Pattern in project lombok by rzwitserloot.
the class JavacHandlerUtil method stripLinesWithTagFromJavadoc.
public static String stripLinesWithTagFromJavadoc(String javadoc, String regexpFragment) {
Pattern p = Pattern.compile("^\\s*\\**\\s*" + regexpFragment + "\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(javadoc);
return m.replaceAll("");
}
use of java.util.regex.Pattern in project antlrworks by antlr.
the class FindAndReplace method prev.
public boolean prev() {
if (findString == null || findString.length() == 0)
return false;
int position = delegate.getTextPane().getSelectionStart();
String text = delegate.getText();
Pattern p = getCompiledPattern();
if (p == null)
return false;
Matcher m = p.matcher(text.substring(0, position));
int matchStart = 0;
int matchEnd = 0;
boolean matched = false;
while (m.find(matchEnd)) {
matchStart = m.start();
matchEnd = m.end();
matched = true;
}
if (matched) {
delegate.getTextEditor().selectTextRange(matchStart, matchEnd);
return true;
} else {
return false;
}
}
use of java.util.regex.Pattern in project antlrworks by antlr.
the class FindAndReplace method next.
public boolean next() {
if (findString == null || findString.length() == 0)
return false;
int position = delegate.getTextPane().getSelectionEnd();
String text = delegate.getText();
Pattern p = getCompiledPattern();
if (p == null)
return false;
Matcher m = p.matcher(text);
if (m.find(position)) {
delegate.getTextEditor().selectTextRange(m.start(), m.end());
return true;
} else {
return false;
}
}
use of java.util.regex.Pattern in project antlrworks by antlr.
the class FindAndReplace method replaceAll.
public void replaceAll() {
Pattern p = getCompiledPattern();
if (p == null)
return;
Matcher m = p.matcher(delegate.getText());
String s = m.replaceAll(replaceString);
int oldCursorPosition = delegate.getTextEditor().getCaretPosition();
delegate.setText(s);
delegate.getTextEditor().setCaretPosition(oldCursorPosition, false, false);
}
Aggregations