Class StringUtil


  • public class StringUtil
    extends Object
    A set of utilities to parse strings. It contains
    Author:
    carcassi
    • Field Detail

      • STRING_ESCAPE_SEQUENCE_REGEX

        public static final String STRING_ESCAPE_SEQUENCE_REGEX
        The pattern of a string fragment with escape sequences.
        See Also:
        Constant Field Values
      • QUOTED_STRING_REGEX

        public static final String QUOTED_STRING_REGEX
        The pattern of a string, including double quotes.
        See Also:
        Constant Field Values
      • SINGLEQUOTED_STRING_REGEX

        public static final String SINGLEQUOTED_STRING_REGEX
        The pattern of a string using single quotes.
        See Also:
        Constant Field Values
      • DOUBLE_REGEX_WITH_NAN

        public static final String DOUBLE_REGEX_WITH_NAN
        The pattern of a double value.
        See Also:
        Constant Field Values
    • Method Detail

      • unquote

        public static String unquote​(String quotedString)
        Takes a single quoted or double quoted String and returns the unquoted and unescaped version of the string.
        Parameters:
        quotedString - the original string
        Returns:
        the unquoted string
      • unescapeString

        public static String unescapeString​(String escapedString)
        Takes an escaped string and returns the unescaped version
        Parameters:
        escapedString - the original string
        Returns:
        the unescaped string
      • parseCSVLine

        public static List<Object> parseCSVLine​(String line,
                                                String separatorRegex)
        Parses a line of text representing comma separated values and returns the values themselves.
        Parameters:
        line - the line to parse
        separatorRegex - the regular expression for the separator
        Returns:
        the list of values