package bjc.utils.funcutils; import java.util.regex.Pattern; /** * Split a string and keep given delimiters. * * @author Ben Culkin */ public class NeoTokenSplitter { /* * This string is a format template for the delimiter matching regex * * It does two things * 1. Match the provided delimiter by positive lookahead * 2. Match the provided delimiter by positive lookbehind * * Thus, it will only match in places where the delimiter is, but won't * actually match the delimiter, leaving split to put it into the stream */ private static String WITH_DELIM = "((?<=%1$s)|(?=%1$s))"; /* * This string is a format template for the multi-delimiter matching * regex. * * It does the same thing as the single delimiter regex, but has to have * some negative lookahead/lookbehind assertions to avoid splitting a * delimiter into pieces. */ private static String WITH_MULTI_DELIM = "((?<=%1$s+)(?!%1$s)|(?