public class Str extends Object
Constructor and Description |
---|
Str() |
Modifier and Type | Method and Description |
---|---|
static String |
capitalizeFirst(String sSource)
Convert each letter after space to Upper Case and all others to Lower Case
|
static String |
capitalizeFirstAndSecond(String sSource)
Convert each letter after space to Upper Case
if the word has exactly two characters then UpperCase also the second letter
convert all other letters to Lower Case
|
static String |
chomp(String sSource,
String sEndsWith)
Ensure that a String ends with a given substring
|
static String |
dechomp(String sSource,
char cEndsWith)
Ensure that a String does not end with a given character
|
static boolean |
in(String sStr,
String[] aSet)
Search for a String in an array
|
static int |
indexOfIgnoreCase(String sSource,
String sSought)
Get index of a substring inside another string
|
static int |
indexOfIgnoreCase(String sSource,
String sSought,
int iStartAt)
Get index of a substring inside another string
|
static String |
left(String sSource,
int nChars)
Get the leftmost characters of a String
|
static String |
leftPad(String sSource,
char cPad,
int nChars)
Add padding characters to the left.
|
static int |
levenshteinDistance(String s,
String t)
Calculate Levenshtein distance between two strings
|
static String |
removeChars(String sInput,
String sRemove)
Remove a character set from a String
|
static String |
substrAfter(String sSource,
int iFromIndex,
String sSought)
Get substring after a given character sequence
|
static String |
substrBetween(String sSource,
String sLowerBound,
String sUpperBound)
Get substring between two given character sequence
|
static String |
substrUpTo(String sSource,
int iFromIndex,
char cSought)
Get substring from an index up to next given character
|
static String |
substrUpTo(String sSource,
int iFromIndex,
String sSought)
Get substring from an index up to next given character sequence
|
public static String chomp(String sSource, String sEndsWith)
sSource
- Input StringsEndsWith
- Substring that the String must end with.public static String dechomp(String sSource, char cEndsWith)
sSource
- Input StringcEndsWith
- Character that the String must not end with.public static boolean in(String sStr, String[] aSet)
sStr
- String soughtaSet
- String[] Strings searchedpublic static String removeChars(String sInput, String sRemove)
sInput
- Input StringsRemove
- A String containing all the characters to be removed from input Stringpublic static int indexOfIgnoreCase(String sSource, String sSought, int iStartAt)
sSource
- String String to be scannedsSought
- Substring to be soughtiStartAt
- int Index to start searching frompublic static int indexOfIgnoreCase(String sSource, String sSought)
sSource
- String String to be scannedsSought
- Substring to be soughtpublic static String substrAfter(String sSource, int iFromIndex, String sSought) throws StringIndexOutOfBoundsException, NullPointerException
sSource
- Source StringiFromIndex
- Index top start searching character sequence fromsSought
- Character sequence soughtStringIndexOutOfBoundsException
NullPointerException
- is source or sought string is nullpublic static String substrUpTo(String sSource, int iFromIndex, char cSought) throws StringIndexOutOfBoundsException
sSource
- Source StringiFromIndex
- Index top start searching character fromcSought
- Character soughtStringIndexOutOfBoundsException
- if cSought character is not found at sSourcepublic static String substrUpTo(String sSource, int iFromIndex, String sSought) throws StringIndexOutOfBoundsException
sSource
- Source StringiFromIndex
- Index top start searching character fromsSought
- Character sequence soughtStringIndexOutOfBoundsException
- if sSought sequence is not found at sSourcepublic static String substrBetween(String sSource, String sLowerBound, String sUpperBound) throws StringIndexOutOfBoundsException, NullPointerException
sSource
- Source StringsLowerBound
- Lower bound character sequencesUpperBound
- Upper bound character sequenceStringIndexOutOfBoundsException
NullPointerException
public static String left(String sSource, int nChars) throws ArrayIndexOutOfBoundsException
sSource
- Source StringnChars
- Number of charactersArrayIndexOutOfBoundsException
- If nChars<0public static String leftPad(String sSource, char cPad, int nChars)
sSource
- Input StringcPad
- Padding characternChars
- Final length of the padded stringpublic static int levenshteinDistance(String s, String t)
Calculate Levenshtein distance between two strings
The Levenshtein distance is defined as the minimal number of characters you have to replace, insert or delete to transform s into t. The complexity of the algorithm is O(m*n), where n and m are the length of s and t.s
- Stringt
- StringIllegalArgumentException
- if either s or t is nullpublic static String capitalizeFirst(String sSource)
sSource
- Source Stringpublic static String capitalizeFirstAndSecond(String sSource)
sSource
- Source StringCopyright © 2001–2019 KnowGate. All rights reserved.