Defines the all lower case format (All letters on a string written with lower case letters only)
Defines the all upper case format (All letters on a string written with Capital letters only)
Defines the CamelCase format (the practice of writing compound words or phrases such that each word or abbreviation begins with a capital letter)
Defines the first upper rest lower case format (All letters on a string written with lower case letters except the first one which is Capitalized)
Defines the lowerCamelCase format variation that writes first letter as lower case
Defines the lower_snake_case format variation that writes all letters as lower case
Defines the sentence case format (Only the first character of the sentence is capitalised,except for proper nouns and other words which are required by a more specific rule to be capitalised). Generally equivalent to the baseline universal standard of formal English orthography
Defines the snake_case format (the practice of writing compound words or phrases in which the elements are separated with one underscore character (_) and no spaces)
Defines the start case format (The first character in all words capitalised and all the rest of the word lower case). It is also called Title Case
Defines the UpperCamelCase format variation that writes first letter as upper case
Defines the FORMAT_UPPER_SNAKE_CASE format variation that writes all letters as upper case
Compares two strings and gives the number of character replacements that must be performed to convert one of the strings into the other. A very useful method to use in fuzzy text searches where we want to look for similar texts. This method uses the Levenshtein method for the comparison:
The Levenshtein distance is defined as the minimal number of characters you have to replace, insert or delete to transform string1 into string2. The complexity of the algorithm is O(m*n), where n and m are the length of string1 and string2.
The first string to compare
The second string to compare
The number of characters to replace to convert $string1 into $string2 where 0 means both strings are the same. The higher the result, the more different the strings are.
Compares the percentage of similarity between two strings, based on the Levenshtein method. A very useful method to use in fuzzy text searches where we want to look for similar texts.
The first string to compare
The second string to compare
A number between 0 and 100, being 100 if both strings are the same and 0 if both strings are totally different
Given a string with a list of elements separated by '/' or '' that represent some arbitrary path structure, this method will return the number of elements that are listed on the path.
A string containing some arbitrary path.
The number of elements that are listed on the provided path
Count the number of times a string is found inside another string
The string where we want to search
The string that we want to look for
The number of times that findMe appears on string
Count the number of words that exist on the given string
The string which words will be counted
' ' by default. The character that is considered as the word sepparator
The number of words (elements divided by the wordSeparator value) that are present on the string
Changes the letter case for the given string to the specified format.
A string that will be processed to match the specified case format.
The format to which the given string will be converted. Possible values are defined as StringUtils constants that start with FORMAT_, like: StringUtils.FORMAT_ALL_UPPER_CASE
The given string converted to the specified case format.
Given a string with a list of elements separated by '/' or '' that represent some kind of unformatted path, this method will process it to get a standarized one by applying the following rules:
NOTE: This method only applies format to the received string. It does not check if the path is a real location or a valid url, and won't also fail if the received path contains strange characters or is invalid.
A raw path to be formatted
The character to use as the element divider. Only slash '/' or backslash '' are allowed.
The correctly formatted path without any trailing separator
Given a raw string containing an internet URL, this method will process it to obtain a URL that is 100% format valid.
A Uniform Resource Locator (URL), commonly informally termed a web address is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. URLs occur most commonly to reference web pages (http), but are also used for file transfer (ftp), email (mailto), database access (JDBC), and many other applications.
Every HTTP URL conforms to the syntax of a generic URI. A generic URI is of the form: scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
The formated url string or the original string if it was not a valid url
Generates a random string with the specified length and options
Specify the minimum possible length for the generated string
Specify the maximum possible length for the generated string
Defines the list of possible characters to be generated. Each element of charSet must be a string containing the possible characters like 'a1kjuhAO' or a range like 'a-z', 'A-D', '0-5', ... etc. Note that - character must be escaped - when not specified as part of a range. Default charset is alphanumeric ['0-9', 'a-z', 'A-Z']
A randomly generated string
Extracts the domain name from a given url (excluding subdomain). For example: http://subdomain.google.com/test/ will result in 'google.com'
A string containing an URL
The domain from the given string (excluding the subdomain if exists)
Extracts the hostname (domain + subdomain) from a given url. For example: http://subdomain.google.com/test/ will result in 'subdomain.google.com'
A string containing an URL
The domain and subdomain from the given string (subdomain.domain.com)
Extracts all the lines from the given string and outputs an array with each line as an element. It does not matter which line separator's been used (\n, \r, Windows, linux...). All source lines will be correctly extracted.
Text containing one or more lines that will be converted to an array with each line on a different element.
One or more regular expressions that will be used to filter unwanted lines. Lines that match any of the filters will be excluded from the result. By default, all empty lines are ignored (those containing only newline, blank, tabulators, etc..).
A list with all the string lines sepparated as different array elements.
Given a string with a list of elements separated by '/' or '' that represent some arbitrary path structure, this method will format the specified path and remove the number of requested path elements (from its right side) and return the path without that elements.
This method can be used with Operating system file paths, urls, or any other string that uses the 'slash separated' format to encode a path.
A string containing some arbitrary path.
(one by default) The number of elements that we want to remove from the right side of the path.
The character to use as the element divider for the returned path. Only slash '/' or backslash '' are allowed.
The received path without the specified number of elements and correctly formatted
Given a string with a list of elements separated by '/' or '' that represent some arbitrary path structure, this method will return the element that is located at the requested position. If no position is defined, the last element of the path will be returned (the most to the right one).
This method can be used with Operating system file paths, urls, or any other string that uses the 'slash separated' format to encode a path.
A string containing some arbitrary path.
The index for the element that we want to extract from the path. If not specified, the last one will be returned. (Positions go from left to right)
The element at the specified path position or the last one if no position is defined
This method works in the same way as getPathElement but it also removes the extension part from the result if it has any.
A string containing some arbitrary path.
The index for the element that we want to extract from the path. If not specified, the last one will be returned.
The character to be used as the extension separator. The most commonly used is '.'
The element at the specified path position with it's extension removed or the last one if no position is defined
This method works in the same way as getPathElement but it only gives the element extension if it has any.
A string containing some arbitrary path.
The index for the element extension that we want to extract from the path. If not specified, the last one will be returned.
The character to be used as the extension separator. The most commonly used is '.'
The extension from the element at the specified path position or the extension from the last one if no position is defined
Given an internet URL, this method extracts only the scheme part. Example: "http://google.com" -> results in "http"
A valid internet url
('ftp', 'http', ...) if the url is valid or '' if the url is invalid
Tells if a specified string is empty. The string may contain empty spaces, and new line characters but have some length, and therefore be EMPTY. This method checks all these different conditions that can tell us that a string is empty.
String to check
List of strings that will be also considered as empty characters. For example, if we also want to define 'NULL' and '' as empty string values, we can set this to ['NULL', '']
false if the string is not empty, true if the string contains only spaces, newlines or any other characters defined as "empty" values
Tells if the given value is a string or not
A value to check
true if the given value is a string, false otherwise
Tells if the given string is a valid url or not
The value to check
False in case the validation fails or true if validation succeeds.
Method that limits the length of a string and optionally appends informative characters like ' ...' to inform that the original string was longer.
String to limit
Max number of characters
If the specified text exceeds the specified limit, the value of this parameter will be added to the end of the result. The value is ' ...' by default.
The specified string but limited in length if necessary. Final result will never exceed the specified limit, also with the limiterString appended.
Converts all accent characters to ASCII characters on a given string.
This method is based on a stack overflow implementation called removeDiacritics
Text from which accents must be cleaned
The given string with all accent and diacritics replaced by the respective ASCII characters.
Replace all occurrences of the search string with the replacement string
The string or array being searched and replaced on, otherwise known as the haystack.
The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles (if we use an array, the order of replacement will be the same of the array: First element will be the first one to be replaced, second element the second, etc..)
The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
If passed and > 0, this will define the maximum number of replacements to perform
The string with all the replaced values
Remove whitespaces (or any custom set of characters) from both sides of a string
A string to process
A set of characters that will be trimmed from both string sides. By default, empty space and new line characters are defined : " \n\r"
The trimmed string
Remove whitespaces (or any custom set of characters) from a string left side
A string to process
A set of characters that will be trimmed from string left side. By default, empty space and new line characters are defined : " \n\r"
The trimmed string
Remove whitespaces (or any custom set of characters) from a string right side
A string to process
A set of characters that will be trimmed from string right side. By default, empty space and new line characters are defined : " \n\r"
The trimmed string
Generated using TypeDoc
The most common string processing and modification utilities