Example usage for java.util.regex Pattern DOTALL

List of usage examples for java.util.regex Pattern DOTALL

Introduction

In this page you can find the example usage for java.util.regex Pattern DOTALL.

Prototype

int DOTALL

To view the source code for java.util.regex Pattern DOTALL.

Click Source Link

Document

Enables dotall mode.

Usage

From source file:ubic.pubmedgate.resolve.mentionEditors.BracketRemoverMentionEditor.java

public Set<String> editMention(String mention) {
    String olds = mention;//w w w  .j  av a 2s .c o  m
    Set<String> result = new HashSet<String>();
    String regex = "\\s?\\((.*?)\\)\\s?";
    Pattern p = Pattern.compile(regex, Pattern.DOTALL);
    Matcher m = p.matcher(mention);

    if (m.find()) {
        mention = m.replaceAll(" ");
        // log.info( olds + " -> " + mention );
        result.add(mention);
    }
    return result;
}

From source file:de.ist.clonto.webwiki.InfoboxParser.java

public List<Information> parse(String text) {
    String pagetext = replaceHTMLComments(text);
    List<Information> setlist = new ArrayList<Information>();

    Pattern pattern = Pattern.compile("\\{\\{\\s*infobox",
            Pattern.MULTILINE | Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
    Matcher matcher = pattern.matcher(pagetext);
    while (matcher.find()) {
        int begin = matcher.start();
        int bracketnr = 2;
        int end = begin + matcher.group().length();
        while (end < pagetext.length()) {
            switch (pagetext.charAt(end)) {
            case '}':
                bracketnr--;/*from ww w.ja va2s  .  c  o  m*/
                break;
            case '{':
                bracketnr++;
                break;
            }
            if (bracketnr == 0) {
                break;
            }
            end++;
        }
        String infobox = pagetext.substring(begin, end);
        Information info = parseSet(infobox);
        setlist.add(info);
    }

    return setlist;
}

From source file:com.conversantmedia.mapreduce.tool.ExpressionEvaluator.java

private ExpressionEvaluator() {
    this.pattern = Pattern.compile("(.*)\\$\\{(.+)\\}(.*)", Pattern.DOTALL);
}

From source file:org.sonar.plugins.github.MarkDownUtils.java

private static String getLocation(String url) {
    String filename = Pattern.compile(".*/", Pattern.DOTALL).matcher(url).replaceAll(StringUtils.EMPTY);
    if (filename.length() <= 0) {
        filename = "Project";
    }/*from  w  w  w .ja v  a2 s . com*/

    return filename;
}

From source file:com.android.dialer.lookup.LookupUtils.java

public static String firstRegexResult(String input, String regex, boolean dotall) {
    if (input == null) {
        return null;
    }/*  w ww  . java 2  s .  c om*/
    Pattern pattern = Pattern.compile(regex, dotall ? Pattern.DOTALL : 0);
    Matcher m = pattern.matcher(input);
    return m.find() ? m.group(1).trim() : null;
}

From source file:org.apache.tajo.plan.expr.RegexPredicateEval.java

protected void compile(String regex) throws PatternSyntaxException {
    int flags = Pattern.DOTALL;
    if (caseInsensitive) {
        flags |= Pattern.CASE_INSENSITIVE;
    }/*from  w ww  .  j a  v a 2  s .  c  o  m*/
    this.compiled = Pattern.compile(StringEscapeUtils.unescapeJava(regex), flags);
}

From source file:org.eclipse.recommenders.tests.jdt.JavaProjectFixture.java

public static String findClassName(final CharSequence source) {
    Pattern p = Pattern.compile(".*?class\\s+(\\w+).*", Pattern.DOTALL);
    Matcher matcher = p.matcher(source);
    if (!matcher.matches()) {
        p = Pattern.compile(".*interface\\s+(\\w+).*", Pattern.DOTALL);
        matcher = p.matcher(source);/*from w w  w  . j  a v a  2  s .c om*/
    }
    assertTrue(matcher.matches());
    final String group = matcher.group(1);
    return group;
}

From source file:dbpedia.provenance.AuthorMetadata.java

public Integer WikiUserEditCount(String sUser) {
    Integer cnt = -1;//from w w w.j  av a  2 s  .  co m
    String url = String.format("http://en.wikipedia.org/w/api.php?action=query&list=users&ususers=" + sUser
            + "&usprop=editcount&format=xml");
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(url);

    try {
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        String response = httpclient.execute(httppost, responseHandler);

        String pattern = "editcount=\"(.*)\"";
        Pattern r = Pattern.compile(pattern, Pattern.DOTALL);
        Matcher m = r.matcher(response);
        if (m.find()) {
            cnt = Integer.valueOf(m.group(1));
            // System.out.println("number of edits, user " + sUser + ": " + m.group(1) );
        }
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
    }

    return cnt;
}

From source file:edu.pitt.dbmi.edda.operator.regexop.regex.RegularExpression.java

public RegularExpression(String name, String value, int regularExpressionNumber) {
    this.name = name;
    this.value = value;
    this.regularExpressionNumber = regularExpressionNumber;
    this.key = ":" + StringUtils.leftPad(regularExpressionNumber + "", 10, "0");
    /* @todo//from  w ww .  j av a2 s  .c o  m
     *    Add regex parameters into UI
     */
    //      this.pattern = Pattern.compile(value, Pattern.DOTALL
    //            | Pattern.CASE_INSENSITIVE);
    this.pattern = Pattern.compile(value, Pattern.DOTALL);
}

From source file:com.seajas.search.contender.service.modifier.ModifierFilterProcessor.java

/**
 * Process the given reader using this filter.
 * //  w ww.  jav  a  2  s.c  om
 * @param filter
 * @param reader
 * @return Reader
 * @throws IOException
 */
public Reader process(final ModifierFilter filter, final Reader reader) throws IOException {
    StringBuffer stringBuffer = new StringBuffer();

    for (int c; (c = reader.read()) != -1;)
        stringBuffer.append((char) c);

    reader.close();

    if (!filter.getIsExpression()) {
        Pattern pattern = Pattern.compile(
                Pattern.quote(filter.getFragmentStart()) + ".*" + Pattern.quote(filter.getFragmentEnd()),
                Pattern.DOTALL | Pattern.CASE_INSENSITIVE);

        return new StringReader(
                pattern.matcher(stringBuffer).replaceAll(filter.getFragmentStart() + filter.getFragmentEnd()));
    } else {
        Matcher startMatcher = Pattern.compile(filter.getFragmentStart(), Pattern.CASE_INSENSITIVE)
                .matcher(stringBuffer),
                endMatcher = Pattern.compile(filter.getFragmentEnd(), Pattern.CASE_INSENSITIVE)
                        .matcher(stringBuffer);

        while (startMatcher.find() && endMatcher.find(startMatcher.end()))
            if (startMatcher.end() != endMatcher.start()) {
                stringBuffer.delete(startMatcher.end(), endMatcher.start());

                startMatcher.reset();
                endMatcher.reset();
            }

        // Store the result

        return new StringReader(stringBuffer.toString());
    }
}