Swiftpack.co - flowbe/SwiftRegex as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by flowbe.
flowbe/SwiftRegex 1.0.0
Wrapper around NSRegularExpression for Swift
⭐️ 3
🕓 3 years ago
.package(url: "https://github.com/flowbe/SwiftRegex.git", from: "1.0.0")

SwiftRegex

SwiftRegex is a simple wrapper around NSRegularExpression to simplify the usage of regular expression in Swift.

Installation

Installation can be done via Swift Package Manager or by dragging Sources/SwiftRegex into your project.

dependencies: [
    .package(url: "https://github.com/flowbe/SwiftRegex.git", .upToNextMajor(from: "1.0.0"))
]

Example usage

if let regex = Regex(pattern: #"\b(a|b)(c|d)\b"#, options: .caseInsensitive) {
    print(regex.numberOfMatches(in: "Ad eternam")) // Prints 1
} else {
    // The regular expression pattern is invalid.
}

The wrapper contains almost the same methods as NSRegularExpression but you don't need to manipulate inconvenient NSRange or NSTextCheckingResult. It also adds a split method.

GitHub

link
Stars: 3
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.0.0
3 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics