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:info.magnolia.cms.util.SimpleUrlPattern.java

/**
 * Mainly used by ContentToBean.//from   ww w  . j  a  v a2  s  .  c  o  m
 */
public void setPatternString(String patternString) {
    this.length = StringUtils.removeEnd(patternString, "*").length();
    this.pattern = Pattern.compile(getEncodedString(patternString), Pattern.DOTALL);
    this.patternString = patternString;
}

From source file:com.liferay.ide.project.core.upgrade.UpgradeMetadataHandler.java

private String getNewDoctTypeSetting(String doctypeSetting, String newValue, String regrex) {
    String newDoctTypeSetting = null;
    Pattern p = Pattern.compile(regrex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
    Matcher m = p.matcher(doctypeSetting);

    if (m.find()) {
        String oldVersionString = m.group(m.groupCount());
        newDoctTypeSetting = doctypeSetting.replace(oldVersionString, newValue);
    }/*from   w  w w .  j ava2s  . c  o  m*/

    return newDoctTypeSetting;
}

From source file:TelnetTest.java

public void testFTP_Telnet_Remote_Execution_002() throws IOException {
    os.write("ps\r\n".getBytes());
    os.flush();// w ww .  jav  a  2 s.c  o m

    String s = readUntil(is, prompt);

    s = s.substring(0, s.indexOf(prompt));

    //   System.out.println(s);

    Pattern p = Pattern.compile(".*ps.EXE\\[2000ee91\\]\\d\\d\\d\\d\r\n$",
            Pattern.DOTALL | Pattern.CASE_INSENSITIVE); //Pattern.DOTALL => '.' includes end of line
    Matcher m = p.matcher(s);
    assertTrue(m.matches());
}

From source file:net.sourceforge.jwbf.actions.mw.queries.GetCategoryMembers.java

/**
 * gets the information about a follow-up page from a provided api response.
 * If there is one, a new request is added to msgs by calling generateRequest.
 *   //  w  w w . ja  v  a2  s  . c o  m
 * @param s   text for parsing
 */
private void parseHasMore(final String s) {

    // get the blcontinue-value

    Pattern p = Pattern.compile(
            "<query-continue>.*?" + "<categorymembers *cmcontinue=\"([^\"]*)\" */>" + ".*?</query-continue>",
            Pattern.DOTALL | Pattern.MULTILINE);

    Matcher m = p.matcher(s);

    if (m.find()) {
        nextPageInfo = m.group(1);
    }

}

From source file:tk.tomby.tedit.core.snr.FindReplaceWorker.java

/**
 * DOCUMENT ME!// w  w w  .j a  va  2  s  .c  o m
 *
 * @param lineNumber DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
private Element init(int lineNumber) {
    Document doc = buffer.getDocument();
    Element line = doc.getDefaultRootElement().getElement(lineNumber);

    try {
        int options = Pattern.DOTALL;

        String find = PreferenceManager.getString("snr.find", "");

        if ((find != null) && !find.equals("")) {
            if (PreferenceManager.getBoolean("snr.case", false)) {
                find = find.toLowerCase();

                options |= Pattern.CASE_INSENSITIVE;
            }

            if (PreferenceManager.getBoolean("snr.whole", false)) {
                find = "\\b" + find + "\\b";
            }

            int offset = line.getStartOffset();
            int length = line.getEndOffset() - offset;

            if (PreferenceManager.getInt("snr.direction", FORWARD) == FORWARD) {
                if ((buffer.getSelectionEnd() > line.getStartOffset())
                        && (buffer.getSelectionEnd() <= line.getEndOffset())) {
                    offset = buffer.getSelectionEnd();
                    length = line.getEndOffset() - offset;
                }
            } else {
                if ((buffer.getSelectionStart() > line.getStartOffset())
                        && (buffer.getSelectionStart() <= line.getEndOffset())) {
                    length = buffer.getSelectionStart() - offset;
                }
            }

            String text = doc.getText(offset, length);

            Pattern pattern = Pattern.compile(find, options);

            this.matcher = pattern.matcher(text);
        }
    } catch (BadLocationException e) {
        log.error(e.getMessage(), e);
    }

    return line;
}

From source file:application.Crawler.java

/**
 *
 * @param text//w  w w .  j a  va2 s  . co  m
 * @return double
 */
private double extractUnitPrice(String text) {

    String res = null;

    Pattern p = Pattern.compile("<p.*\"pricePerUnit\">(.*)<abbr title=\"per\">", Pattern.DOTALL);
    Matcher m = p.matcher(text);
    while (m.find()) {
        String group = m.group(1);
        res = group.substring(3);
    }

    return Double.parseDouble(res);
}

From source file:com.thoughtworks.cruise.utils.configfile.CruiseConfigUtil.java

private static Matcher matcher(String pattern, String contents) {
    return Pattern.compile(pattern, Pattern.DOTALL).matcher(contents);
}

From source file:com.etime.ETimeUtils.java

/**
 * Return a List of Punches for the current day. The list is empty if there are no punches for today.
 *
 * @param page the raw html of the user's timecard page
 * @return A list of Punches for the current day.
 */// www  . jav a2  s  .c o m
protected static List<Punch> getTodaysPunches(String page) {
    String curRow;
    String date;
    List<Punch> punchesList = new LinkedList<Punch>();

    Calendar calendar = Calendar.getInstance();
    int month = calendar.get(Calendar.MONTH) + 1;
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    String dayOfWeek = daysOfWeek[calendar.get(Calendar.DAY_OF_WEEK) - 1];

    if (day < 10) {
        date = dayOfWeek + " " + Integer.toString(month) + "/0" + Integer.toString(day);
    } else {
        date = dayOfWeek + " " + Integer.toString(month) + "/" + Integer.toString(day);
    }
    try {
        Pattern todaysRowsPattern = Pattern.compile("(?i)(>" + date + ")(.*?)(</tr>)",
                Pattern.MULTILINE | Pattern.DOTALL);
        Matcher todaysRowsMatcher = todaysRowsPattern.matcher(page);
        while (todaysRowsMatcher.find()) {
            curRow = todaysRowsMatcher.group(2);
            addPunchesFromRowToList(curRow, punchesList);
        }
    } catch (Exception e) {
        Log.w(TAG, e.toString());
    }

    return punchesList;
}

From source file:com.wso2telco.dep.mediator.impl.DefaultExecutor.java

/**
 * Read msisdn./* w  ww .  j ava 2  s.c o m*/
 *
 * @param context the context
 * @return the string
 * @throws Exception the exception
 */
private String readMSISDN(MessageContext context) throws Exception {
    String msisdnLocation = (String) context.getProperty(MSISDNConstants.MSISDN_LOCATION_PROPERTY);
    String msisdnRegex = (String) context.getProperty(MSISDNConstants.MSISDN_REGEX_PROPERTY);
    String msisdnResource = null;

    if (msisdnLocation == null || msisdnRegex == null) {
        log.error("Missing required properties for DefaultExecutor. Synapse properties default.MSISDN.location "
                + "and/or default.MSISDN.regex is missing");
        throw new Exception("Missing required properties for DefaultExecutor");
    }

    if (msisdnLocation.equalsIgnoreCase("URL")) {
        msisdnResource = URLDecoder.decode(getSubResourcePath().replace("+", "%2B"), "UTF-8");
    } else if (msisdnLocation.equalsIgnoreCase("Body")) {
        msisdnResource = getJsonBody().toString();
    }

    Pattern pattern = Pattern.compile(msisdnRegex, Pattern.DOTALL);
    Matcher matcher = pattern.matcher(msisdnResource);

    String result = null;
    while (matcher.find()) {
        result = matcher.group();
        result = result.replace("tel:", "");
    }
    if (log.isDebugEnabled()) {
        log.debug("MSISDN Location - " + msisdnLocation);
        log.debug("MSISDN Regex - " + msisdnRegex);
        log.debug("MSISDN Resource Text - " + msisdnResource);
        log.debug("MSISDN Matched Result - " + result);
    }
    return result;
}

From source file:org.opennms.web.rest.AcknowledgmentRestServiceTest.java

@Test
@JUnitTemporaryDatabase/*from  w  w  w .j a v  a 2  s.c o m*/
public void testAcknowlegeAlarm() throws Exception {
    final Pattern p = Pattern.compile("^.*<ackTime>(.*?)</ackTime>.*$", Pattern.DOTALL & Pattern.MULTILINE);
    sendData(POST, MediaType.APPLICATION_FORM_URLENCODED, "/acks", "alarmId=1&action=ack");
    String xml = sendRequest(GET, "/alarms/1", new HashMap<String, String>(), 200);
    Matcher m = p.matcher(xml);
    assertTrue(m.matches());
    assertTrue(m.group(1).length() > 0);
    sendData(POST, MediaType.APPLICATION_FORM_URLENCODED, "/acks", "alarmId=1&action=unack");
    xml = sendRequest(GET, "/alarms/1", new HashMap<String, String>(), 200);
    m = p.matcher(xml);
    assertFalse(m.matches());
}