CharacterSetPredicate

public struct CharacterSetPredicate : Predicate

The CharacterSetPredicate struct is used to evaluate a String inputs agains a defined CharacterSet.

  • The Mode enum is used to set the evaluation mode of the input’s character set against the character set provided at initialisation.

    See more

    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 given String 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 given Srings 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, otherwise false.