Contents

anyOf(_:)

Returns a character class that matches any character in the given string or sequence.

Declaration

static func anyOf<S>(_ s: S) -> CharacterClass where S : Sequence, S.Element == Character

Discussion

Calling this method with a group of characters is equivalent to listing those characters in a custom character class in regex syntax. For example, the two regexes in this example are equivalent:

let regex1 = /[abcd]+/
let regex2 = OneOrMore(.anyOf("abcd"))

See Also

Matching substring sequences