Java String Split by Delimiter splitHtmlTagKeepDelimiter(String tag, String input)

Here you can find the source of splitHtmlTagKeepDelimiter(String tag, String input)

Description

split Html Tag Keep Delimiter

License

Open Source License

Declaration

public static List<String> splitHtmlTagKeepDelimiter(String tag, String input) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Arrays;

import java.util.List;

public class Main {
    public static List<String> splitHtmlTagKeepDelimiter(String tag, String input) {
        return splitHtmlTagKeepDelimiter(tag, 100, input);
    }/* w w  w .  j ava 2s .c  om*/

    public static List<String> splitHtmlTagKeepDelimiter(String tag, int max, String input) {
        // max: could not use "+?" because of "Look-behind group does not have
        // an
        // obvious maximum length near index NR"
        String tagRegex = "(<" + tag + ">(.{0," + max + "})</" + tag + ">)";
        return splitKeepDelimiter(tagRegex, input);
    }

    public static List<String> splitKeepDelimiter(String delimiter, String input) {
        return Arrays.asList(input.split(//
                "(?i)" // case insensitive
                        + "((?<="//
                        + delimiter//
                        + ")|(?="//
                        + delimiter//
                        + "))"//
        ));
    }
}

Related

  1. SplitAt(String str, String delimiter)
  2. splitByStr(String s, String delim)
  3. splitChars(String str, String delimiters)
  4. splitFast(String text, char delim)
  5. splitForChar(final String string, final char delimiter)
  6. splitKeepDelimiter(String delimiter, String input)
  7. splitList(String data, String delims)
  8. splitNestedString(String params, String delimStr, int numLeft, int numRight)
  9. splitNoCoalesce(String s, char delimiter)