Skip to content

Commit

Permalink
Add init with empty components to Regex.Match
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Alvarado committed Jun 30, 2019
1 parent 2238dd0 commit 74ff612
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/Regex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public struct Regex {
/// A collection of a tuple object with a value of the substring and the range of that substring from the string it was matched in/
public let components: [(String, Range<String.Index>)]

public init() {
components = [(String, Range<String.Index>)]()
}

public init(components: [(String, Range<String.Index>)]) {
self.components = components
}

/// A collection of just the substrings that were found in the match.
public func subStrings() -> [String] {
return components.map {
Expand Down

0 comments on commit 74ff612

Please sign in to comment.