String Conditions
contains(x): Check if string contains a substring
contains(x): Check if string contains a substringReturns a condition that checks if a string contains a specified substring.
Stream.of(["apple", "banana", "cherry"] \
.filter(contains("na")) \
.for_each(print) # banananot_contains(x): Check if string does not contain a substring
not_contains(x): Check if string does not contain a substringReturns a condition that checks if a string does not contain a specified substring.
Stream.of(["apple", "banana", "cherry"] \
.filter(not_contains("na")) \
.for_each(print) # apple, cherrystarts_with(x): Check if string starts with a substring
starts_with(x): Check if string starts with a substringReturns a condition that checks if a string starts with a specified substring.
Stream.of(["apple", "banana", "cherry"] \
.filter(starts_with("ba")) \
.for_each(print) # bananaends_with(x): Check if string ends with a substring
ends_with(x): Check if string ends with a substringReturns a condition that checks if a string ends with a specified substring.
Stream.of(["apple", "banana", "cherry"] \
.filter(ends_with("ry")) \
.for_each(print) # cherrymatches(x): Check if string matches a regular expression pattern
matches(x): Check if string matches a regular expression patternReturns a condition that checks if a string matches a specified regular expression pattern.
Stream.of(["apple", "banana", "cherry"] \
.filter(matches("^a.*e$")) \
.for_each(print) # applenot_matches(x): Check if string does not match a regular expression pattern
not_matches(x): Check if string does not match a regular expression patternReturns a condition that checks if a string does not match a specified regular expression pattern.
Stream.of(["apple", "banana", "cherry"] \
.filter(not_matches("^a.*e$")) \
.for_each(print) # banana, cherrylonger_than(x): Check if string is longer than a specified length
longer_than(x): Check if string is longer than a specified lengthReturns a condition that checks if a string is longer than a specified length.
Stream.of(["apple", "banana", "cherry"] \
.filter(longer_than(5)) \
.for_each(print) # banana, cherryshorter_than(x): Check if string is shorter than a specified length
shorter_than(x): Check if string is shorter than a specified lengthReturns a condition that checks if a string is shorter than a specified length.
Stream.of(["apple", "banana", "cherry"] \
.filter(shorter_than(6)) \
.for_each(print) # applelonger_than_or_equal(x): Check if string is longer than or equal to a specified length
longer_than_or_equal(x): Check if string is longer than or equal to a specified lengthReturns a condition that checks if a string is longer than or equal to a specified length.
Stream.of(["apple", "banana", "cherry"] \
.filter(longer_than_or_equal(6)) \
.for_each(print) # banana, cherryshorter_than_or_equal(x): Check if string is shorter than or equal to a specified length
shorter_than_or_equal(x): Check if string is shorter than or equal to a specified lengthReturns a condition that checks if a string is shorter than or equal to a specified length.
Stream.of(["apple", "banana", "cherry"] \
.filter(shorter_than_or_equal(5)) \
.for_each(print) # appleequal_to_ignore_case(x): Check if string is equal to another string (case-insensitive)
equal_to_ignore_case(x): Check if string is equal to another string (case-insensitive)Returns a condition that checks if a string is equal to another string, ignoring the case.
Stream.of(["apple", "banana", "cherry"] \
.filter(equal_to_ignore_case("BANANA")) \
.for_each(print) # banananot_equal_to_ignore_case(x): Check if string is not equal to another string (case-insensitive)
not_equal_to_ignore_case(x): Check if string is not equal to another string (case-insensitive)Returns a condition that checks if a string is not equal to another string, ignoring the case.
Stream.of(["apple", "banana", "cherry"] \
.filter(not_equal_to_ignore_case("BANANA")) \
.for_each(print) # apple, cherrycontains_ignore_case(x): Check if string contains a substring (case-insensitive)
contains_ignore_case(x): Check if string contains a substring (case-insensitive)Returns a condition that checks if a string contains a specified substring, ignoring the case.
Stream.of(["apple", "banana", "cherry"] \
.filter(contains_ignore_case("AN")) \
.for_each(print) # apple, banananot_contains_ignore_case(x): Check if string does not contain a substring (case-insensitive)
not_contains_ignore_case(x): Check if string does not contain a substring (case-insensitive)Returns a condition that checks if a string does not contain a specified substring, ignoring the case.
Stream.of(["apple", "banana", "cherry"] \
.filter(not_contains_ignore_case("AN")) \
.for_each(print) # cherrystarts_with_ignore_case(x): Check if string starts with a substring (case-insensitive)
starts_with_ignore_case(x): Check if string starts with a substring (case-insensitive)Returns a condition that checks if a string starts with a specified substring, ignoring the case.
Stream.of(["apple", "banana", "cherry"] \
.filter(starts_with_ignore_case("BA")) \
.for_each(print) # bananaends_with_ignore_case(x): Check if string ends with a substring (case-insensitive)
ends_with_ignore_case(x): Check if string ends with a substring (case-insensitive)Returns a condition that checks if a string ends with a specified substring, ignoring the case.
Stream.of(["apple", "banana", "cherry"] \
.filter(ends_with_ignore_case("RY")) \
.for_each(print) # cherrymatches_ignore_case(x): Check if string matches a regular expression pattern (case-insensitive)
matches_ignore_case(x): Check if string matches a regular expression pattern (case-insensitive)Returns a condition that checks if a string matches a specified regular expression pattern, ignoring the case.
Stream.of(["apple", "banana", "cherry"] \
.filter(matches_ignore_case("^A.*E$")) \
.for_each(print) # applenot_matches_ignore_case(x): Check if string does not match a regular expression pattern (case-insensitive)
not_matches_ignore_case(x): Check if string does not match a regular expression pattern (case-insensitive)Returns a condition that checks if a string does not match a specified regular expression pattern, ignoring the case.
Stream.of(["apple", "banana", "cherry"] \
.filter(not_matches_ignore_case("^A.*E$")) \
.for_each(print) # banana, cherryLast updated
Was this helpful?