Guitar

  • fatalError occurs when using this empty initializer as Guitar must be initialized using init(pattern:) or init(chord:).

    Declaration

    Swift

    public init()
  • Designated Initializer for Guitar

    Declaration

    Swift

    public init(pattern: String)

    Parameters

    pattern

    The pattern that will be used to perform the match.

  • Delegating Initializer for Guitar

    Declaration

    Swift

    public init(chord: Chord)

    Parameters

    chord

    A chord, or built-in regex pattern that will be used to perform the match.

  • Evaluates a string for all instances of a regular expression pattern and returns a list of matched ranges for that string.

    Declaration

    Swift

    public func evaluateForRanges(from string: String, with options: NSRegularExpression.Options = []) -> [Range<String.Index>]

    Parameters

    string

    The string that will be evaluated.

    options

    Regular expression options that are applied to the string during matching. Defaults to [].

    Return Value

    A list of matches.

  • Evaluates a string for all instances of a regular expression pattern and returns a list of matched strings for that string.

    Declaration

    Swift

    public func evaluateForStrings(from string: String, with options: NSRegularExpression.Options = []) -> [String]

    Parameters

    string

    The string that will be evaluated.

    options

    Regular expression options that are applied to the string during matching. Defaults to [].

    Return Value

    A list of matches.

  • Tests a string to see if it matches the regular expression pattern.

    Declaration

    Swift

    public func test(string: String, with options: NSRegularExpression.Options = []) -> Bool

    Parameters

    string

    The string that will be evaluated.

    options

    Regular expression options that are applied to the string during matching. Defaults to [].

    Return Value

    true if string passes the test, otherwise, false.

  • Common Regular Expression Patterns

    See more

    Declaration

    Swift

    enum Chord: String
  • Returns an array containing the first letter of each word in the test string.

    Declaration

    Swift

    static func firstCharacterOfEachWord(in string: String) -> [String]

    Parameters

    string

    The string to evaluate.

    Return Value

    An array containing the first letter of each word in the provided string.

  • Returns an array containing the last letter of each word in the test string.

    Declaration

    Swift

    static func lastCharacterOfEachWord(in string: String) -> [String]

    Parameters

    string

    The string to evaluate.

    Return Value

    An array containing the last letter of each word in the provided string.

  • Tests a string to check if it is a valid email address by using a regular expression.

    Declaration

    Swift

    static func isValidEmail(email: String) -> Bool

    Parameters

    email

    The string that needs to be evaluated.

    Return Value

    true if string is a valid email address, otherwise false.

  • Sanitizes of a string by removing all non-Alphanumeric characters (excluding whitespaces)

    Declaration

    Swift

    static func sanitze(string: String) -> String

    Parameters

    string

    The string that should be sanitized.

    Return Value

    The sanitized string.