Functions

The following functions are available globally.

  • Infix operator for testing if a string matches a regular expression.

    Example

    let sentence = "The world is flat."
    if sentence =~ "^The" {
        // The sentence starts with "The"
    }
    

    Declaration

    Swift

    public func =~ (input: String, pattern: String) -> Bool

    Parameters

    input

    The string that should be tested.

    pattern

    The regular expression that should be used for testing.

  • Infix operator for testing if a string matches a regular expression.

    Example

    let pattern = RegularExpression("^The")!
    let sentence = "The world is flat."
    if sentence =~ pattern {
        // The sentence starts with "The"
    }
    

    Declaration

    Swift

    public func =~ (input: String, pattern: RegularExpression) -> Bool

    Parameters

    input

    The string that should be tested.

    pattern

    The regular expression that should be used for testing.