Search in sources :

Example 51 with Pattern

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);
}
Also used : Pattern(java.util.regex.Pattern) IOException(java.io.IOException)

Example 52 with 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("");
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

Example 53 with Pattern

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;
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

Example 54 with Pattern

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;
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

Example 55 with Pattern

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);
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

Aggregations

Pattern (java.util.regex.Pattern)3181 Matcher (java.util.regex.Matcher)2116 ArrayList (java.util.ArrayList)387 IOException (java.io.IOException)247 Test (org.junit.Test)238 File (java.io.File)193 HashMap (java.util.HashMap)163 BufferedReader (java.io.BufferedReader)127 Field (java.lang.reflect.Field)119 PatternSyntaxException (java.util.regex.PatternSyntaxException)119 Map (java.util.Map)110 List (java.util.List)93 HashSet (java.util.HashSet)79 InputStreamReader (java.io.InputStreamReader)67 InputStream (java.io.InputStream)43 FileReader (java.io.FileReader)41 FileInputStream (java.io.FileInputStream)40 URL (java.net.URL)35 SmallTest (android.test.suitebuilder.annotation.SmallTest)31 LinkedHashMap (java.util.LinkedHashMap)31