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 to the left of the provided delimiter by positive lookahead
  2. *
  3. Match to the right of the provided delimiter by positive lookbehind
  4. *
* * 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)|(?