Here you can find the source of splitEncolosed(String s, char open_tag, char close_tag)
public static ArrayList<String> splitEncolosed(String s, char open_tag, char close_tag)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.util.ArrayList; public class Main { public static ArrayList<String> splitEncolosed(String s, char open_tag, char close_tag) { ArrayList<String> ret = new ArrayList<String>(); char[] chars = s.toCharArray(); String contents = ""; for (char c : chars) { if (c == open_tag) { if (!contents.isEmpty()) { ret.add(contents);/* w w w .j a v a 2 s . c o m*/ } contents = ""; } else if (c == close_tag) { ret.add(contents); contents = ""; } else { contents += c; } } if (!contents.isEmpty()) { ret.add(contents); contents = ""; } return ret; } }