Skip to content

StringUtils.containsNone

Signature: StringUtils.containsNone(inputString, searchChars)

Returns: Boolean result - true if the inputString is null or does not contain any character in the searchChars, false if it does

Checks that the inputString does not contain any character in the searchChars, handling null. A null inputString will return true.

Parameters

Type Name Description Default
String inputString the String to check, may be null
String or char[] searchChars the characters to find

Example

// Examples of how to use StringUtils.containsNone
var text = "Do I contain what you are looking for?";


// Example: searchChars as String
if (StringUtils.containsNone(text, "AYG")) {
   // None of 'A', 'Y' or 'G' appear in the text. The check is case-sensitive, so
   // the lowercase "ayg" would return false.
}


// Example: searchChars as char[]
if (StringUtils.containsNone(
       text,
       ['x', 'Y', 'z']
    )) {
   // Same check with the search characters supplied as an array.
}