Example usage for com.liferay.portal.kernel.util HtmlUtil stripBetween

List of usage examples for com.liferay.portal.kernel.util HtmlUtil stripBetween

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util HtmlUtil stripBetween.

Prototype

public static String stripBetween(String text, String tag) 

Source Link

Document

Strips all content delimited by the tag out of the text.

Usage

From source file:com.liferay.randombibleverse.util.VerseWebCacheItem.java

License:Open Source License

private Verse _getBiblegateway(Verse verse) throws Exception {
    StringBundler sb = new StringBundler();

    sb.append("http://www.biblegateway.com/passage/?search=");
    sb.append(HttpUtil.encodeURL(_location));
    sb.append("&version=");
    sb.append(_versionId);//from   w  w w  .  ja v a2  s .  c  o m

    String text = HttpUtil.URLtoString(sb.toString());

    int x = text.indexOf("result-text-style");
    x = text.indexOf(">", x);

    int y = text.indexOf("</div>", x);

    text = text.substring(x + 1, y);

    y = text.indexOf("Footnotes:");

    if (y != -1) {
        text = text.substring(0, y);
    } else {
        y = text.indexOf("Cross references:");

        if (y != -1) {
            text = text.substring(0, y);
        }
    }

    // Strip everything between <span> and </span>

    text = HtmlUtil.stripBetween(text, "span");

    // Strip everything between <sup> and </sup>

    text = HtmlUtil.stripBetween(text, "sup");

    // Strip everything between <h4> and </h4>

    text = HtmlUtil.stripBetween(text, "h4");

    // Strip everything between <h5> and </h5>

    text = HtmlUtil.stripBetween(text, "h5");

    // Strip HTML

    text = HtmlUtil.stripHtml(text).trim();

    // Strip &nbsp;

    text = StringUtil.replace(text, "&nbsp;", "");

    // Strip carriage returns

    text = StringUtil.replace(text, "\n", "");

    // Strip double spaces

    while (text.indexOf("  ") != -1) {
        text = StringUtil.replace(text, "  ", " ");
    }

    // Replace " with &quot;

    text = StringUtil.replace(text, "\"", "&quot;");

    // Trim

    text = text.trim();

    return new Verse(_location, text);
}