mirror of
https://github.com/shekhargulati/strman-java.git
synced 2026-09-27 05:23:57 +00:00
6986e34fd3f28dd648a4423afeb5cf35cc872298
strman-java
A Java 8 string manipulation library without any dependencies. It is inspired by dleitee/strman.
Available Functions
append(value, strings...)
This method will append strings to the value.
import static strman.Strman.append;
String title = "s";
String result = append(title, "tr","m","an");
// result = "strman"
appendArray(value, strings)
This method will append all the values in strings array to the value.
import static strman.Strman.appendArray;
String title = "s";
String result = appendArray(title, new String[]{"tr","m","an"});
// result = "strman"
at(value, index)
Gets the character at index.
import static strman.Strman.at;
String result = at("foobar", 0);
// result = "f"
between(value, start, end)
Returns array with strings between start and end.
import static strman.Strman.between;
String[] parts = between("[abc][def]", "[", "]";
// parts = ["abc","def"]
chars(value)
Returns a String array consisting of the characters in the String.
final String title = "title";
char[] result = chars(title);
// result = ["t", "i", "t", "l", "e"]
collapseWhitespace(value)
Replace consecutive whitespace characters with a single space.
final String input = " foo bar ";
final String result = collapseWhitespace(title);
// result = "foo bar";
contains(value, needle, caseSensitive)
Verifies that the needle is contained in value.
boolean result = contains("foo bar", "BAR", true);
// result = false
boolean result = contains("foo bar", "FOO");
// result = true
containsAll(value, needles, caseSensitive)
Verifies that all needles are contained in value.
boolean result = containsAll("foo bar", new String[]{"FOO", "bar"});
// result = true
boolean result = containsAll("foo bar", new String[]{"FOO", "bar"}, true);
// result = false
containsAny(value, needles, caseSensitive)
Verifies that one or more of needles are contained in value.
String title = "foo bar";
String needles = ["foo", "bar", "test"];
String result = containsAny(title, needles, true);
// result = true
Other functions that can be added
- head
- tail
Description
A Java 8 library for working with Strings. You can learn about all the String utility functions implemented in strman library by reading the documentation.
481 KiB
Languages
Java
99%
Gradle
1%