Class TextUtil


  • public class TextUtil
    extends Object
    Various static String manipulation methods.
    • Constructor Detail

      • TextUtil

        public TextUtil()
    • Method Detail

      • extractTokens

        public static String[] extractTokens​(String source,
                                             String startDelimiter,
                                             String endDelimiter,
                                             boolean ignoreCase)
        Extracts all tokens from a source that are enclosed by the specified start and enddelimiter.
         $
         values = "pom pom <L>Link</L> en <L>link2</l> tralala.";
         $
         $%extractTokens(values, "<L>", "</L>", false)%$
         $%extractTokens(values, "<L>", "</L>", true)%$
         Output - [Link][Link, link2]
         
        Parameters:
        source - The source from which the tokens should be extacted
        startDelimiter - The start delimiter for the requested tokens
        endDelimiter - The end delimiter for the requested tokens
        ignoreCase - Indicates whether matching of delimiters should be case sensitive
        Returns:
        The array of all tokens that are found between the delimiters in the source
      • filter

        public static String filter​(String source,
                                    String startDelimiter,
                                    String endDelimiter)
        Filters the parts starting with the startDelimiter and ending with the endDelimiter from a string.
        Parameters:
        source - The original string
        startDelimiter - The start tag of the parts that should be filtered
        endDelimiter - The end tag of the parts that be filtered
        Returns:
        The original string from which the parts have been removed
      • split

        public static String[] split​(String string,
                                     char splitter)
        Returns A array of the non-empty string tokens in the source.
        Parameters:
        string - The source that should be splitted into tokens
        splitter - The char that should be used as delimiter
        Returns:
        The array of string tokens in the source
      • join

        public static String join​(Object[] values,
                                  String delimiter)
        Concatenates the elements of an array to a String.
         
        Example: print(join(elements,"+")); Output - text1+text2+text3+text4
        Parameters:
        values - The values that should be joined
        delimiter - The String that is placed between the elements
        Returns:
        A string containing all elements separated by the delimter