Class StringUtils
java.lang.Object
io.github.syst3ms.skriptparser.util.StringUtils
Utility functions for strings
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intCounts combined occurrences of one or more strings in anotherstatic intfindClosingIndex(String pattern, char opening, char closing, int start) Find where a given pair of braces closes.getBracketContent(String s, int start, char closingBracket) Finds the contents until a closing bracket is foundgetEnclosedText(String pattern, char opening, char closing, int start) Similar tofindClosingIndex(String, char, char, int), but returns the enclosed textstatic String[]Returns an array of two elements, containing the plural and singular forms of the given pluralizable expression.getPercentContent(String s, int start) Finds the contents of an expression between %%static intindexOfIgnoreCase(String haystack, String needle, int start) Find the first occurrence of a string in another one, ignoring casestatic StringMirrors the string.static intnextSimpleCharacterIndex(String s, int index) Returns the next character in the string, skipping over curly braces and string literalssplitVerticalBars(String s, SkriptLogger logger) Split a pattern at pipe characters, properly accounting for brackets and escapesstatic StringtoCamelCase(String str, boolean firstNoCase) static StringtoKebabCase(String str, int mode) Converts a string into kebab case.static StringtoReversedCase(String str) Replaces all uppercase characters with lower case ones and vice versa.static StringtoSnakeCase(String str, int mode) Converts a string into snake case.static StringtoTitleCase(String str, boolean allWords) Capitalizes the first word or all words in a string.static StringwithIndefiniteArticle(String noun, boolean plural) Adds a proper English indefinite article to a string
-
Field Details
-
R_LITERAL_CONTENT_PATTERN
-
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
count
-
findClosingIndex
Find where a given pair of braces closes.- Parameters:
pattern- the string to look inopening- the opening braceclosing- the closing bracestart- where the brace pair starts- Returns:
- the index at which the brace pair closes
-
getEnclosedText
public static Optional<String> getEnclosedText(String pattern, char opening, char closing, int start) Similar tofindClosingIndex(String, char, char, int), but returns the enclosed text- Parameters:
pattern- the string to look inopening- the opening braceclosing- the closing bracestart- where the brace pair starts- Returns:
- the enclosed text
-
nextSimpleCharacterIndex
Returns the next character in the string, skipping over curly braces and string literals- Parameters:
s- the string to searchindex- the current index- Returns:
- the index of the next "simple" character, or -1 if the end of the string has been reached
- Throws:
StringIndexOutOfBoundsException- ifindex < 0
-
getPercentContent
-
getBracketContent
Finds the contents until a closing bracket is found- Parameters:
s- the string containing the percentsstart- where the pair beginsclosingBracket- the closing bracket- Returns:
- the content until the closing bracket
-
indexOfIgnoreCase
-
splitVerticalBars
Split a pattern at pipe characters, properly accounting for brackets and escapes- Parameters:
s- the string to splitlogger- the logger- Returns:
- the split string
-
getForms
-
withIndefiniteArticle
-
toTitleCase
-
toCamelCase
-
toSnakeCase
-
toKebabCase
-
toReversedCase
-
mirrored
-