CharacterSetPredicate
public struct CharacterSetPredicate : Predicate
The CharacterSetPredicate
struct is used to evaluate a String
inputs agains a defined CharacterSet
.
-
The
See moreMode
enum is used to set the evaluation mode of the input’s character set against the character set provided at initialisation.Declaration
Swift
public enum Mode
-
Declaration
Swift
public typealias InputType = String
-
Creates and returns a new
CharacterSetPredicate
instance.Declaration
Swift
public init(_ characterSet: CharacterSet, mode: Mode = .strict)
Parameters
characterSet
A
CharacterSet
used to evaluate a givenString
input.mode
A
Mode
that describes how the input’s character set should be evaluated against the character set provided at initialisation. -
Returns a
Boolean
value that indicates whether a givenSrings
contains only characters in the character set.Declaration
Swift
public func evaluate(with input: String) -> Bool
Parameters
input
The input against which to evaluate the receiver.
Return Value
true
if input contains only characters in the charecter set, otherwisefalse
.