Match
public struct Match : Hashable
A regex match.
-
A regex match capture group.
See moreDeclaration
Swift
public struct Group : Hashable
-
The matched string.
Declaration
Swift
public let value: String
-
The range of the matched string in the original string.
Declaration
Swift
public let range: Range<String.Index>
-
All the match groups.
Declaration
Swift
public let groups: [Group]
-
Get a match group by its name.
import Regex Regex(#"(?<number>\d+)"#).firstMatch(in: "1a-2b")?.group(named: "number")?.value //=> "1"
Declaration
Swift
public func group(named name: String) -> Group?