Example usage for org.jsoup.nodes Document getElementsMatchingText

List of usage examples for org.jsoup.nodes Document getElementsMatchingText

Introduction

In this page you can find the example usage for org.jsoup.nodes Document getElementsMatchingText.

Prototype

public Elements getElementsMatchingText(Pattern pattern) 

Source Link

Document

Find elements whose text matches the supplied regular expression.

Usage

From source file:com.screenslicer.common.CommonUtil.java

public static Element getElementMatchingText(Document doc, String tagName, String pattern, boolean ownText) {
    if (doc == null) {
        return null;
    }//  w w w  .ja  v  a 2s  .  c  om
    Elements elements = ownText ? doc.getElementsMatchingOwnText(pattern)
            : doc.getElementsMatchingText(pattern);
    for (Element element : elements) {
        if (element.tagName().equalsIgnoreCase(tagName)) {
            return element;
        }
    }
    return null;
}