Package com.mckoi.util
Class StringUtil
java.lang.Object
com.mckoi.util.StringUtil
Various String utilities.
- Author:
- Tobias Downer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List
Performs an 'explode' operation on the given source string.static int
Finds the index of the given string in the source string.static String
This is the inverse of 'explode'.static String
searchAndReplace
(String source, String search, String replace) Searches for various instances of the 'search' string and replaces them with the 'replace' string.
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
find
Finds the index of the given string in the source string.- Returns:
- -1 if the 'find' string could not be found.
-
explode
Performs an 'explode' operation on the given source string. This algorithm finds all instances of the deliminator string, and returns an array of sub-strings of between the deliminator. For example,explode("10:30:40:55", ":") = ({"10", "30", "40", "55"})
-
implode
This is the inverse of 'explode'. It forms a string by concatinating each string in the list and seperating each with a deliminator string. For example,implode(({"1", "150", "500"}), ",") = "1,150,500"
-
searchAndReplace
Searches for various instances of the 'search' string and replaces them with the 'replace' string.
-