Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. iOS
  3. Regex

Regex

MITSwift2.1.1

A delightful and expressive regular expression type for Swift with pattern matching, capture groups, and Codable support.

GitHubGitHub
610 stars47 forks0 contributors

What is Regex?

Regex is a Swift library that provides a type-safe, expressive interface for working with regular expressions. It solves the problem of cumbersome string-based regex APIs by offering pattern matching in switch statements, easy capture group access, and full Codable support for serialization.

Target Audience

Swift developers working on iOS, macOS, or server-side applications who need to perform text parsing, validation, or pattern matching with regular expressions.

Value Proposition

Developers choose Regex over native Swift regex APIs because it provides a more expressive, type-safe interface with pattern matching integration, capture group utilities, and Codable support that feels native to the Swift language.

Overview

A delightful and expressive regular expression type for Swift.

Use Cases

Best For

  • Validating user input with complex pattern rules
  • Parsing structured text data in Swift applications
  • Implementing search-and-replace functionality with capture groups
  • Building text processing pipelines with pattern matching
  • Creating configuration systems with regex pattern validation
  • Writing expressive text parsing code using switch statements

Not Ideal For

  • Projects requiring cross-language regex consistency outside of Swift
  • Applications where minimal dependencies are critical and native Swift regex APIs suffice
  • Teams that need advanced regex features like lookahead/lookbehind not explicitly covered in the library
  • Simple text validation tasks that can be handled with built-in string methods without regex overhead

Pros & Cons

Pros

Seamless Swift Syntax

Integrates regex directly into Swift switch statements and supports Codable for JSON serialization, making it feel native, as shown in the pattern matching and decode examples.

Intuitive Capture Access

Provides easy-to-use properties like captures and captureRanges for extracting matched substrings, simplifying text parsing without manual range handling.

Flexible Configuration

Supports common regex options such as case-insensitive and multiline matching through the options parameter, enabling adaptable text processing.

Broad Platform Support

Available on all Swift platforms via Swift Package Manager, Carthage, and CocoaPods, with compatibility from Swift 4.2 upward, ensuring wide usability.

Cons

Dynamic Pattern Complexity

Constructing regexes from dynamic strings requires explicit error handling with try-catch, adding boilerplate code and complexity for untrusted inputs.

Exclusive to Swift Ecosystem

Limited to Swift projects, making it irrelevant for cross-platform or multi-language codebases where regex logic needs to be shared.

Potential Performance Overhead

As an abstraction layer over native regex APIs, it may introduce slight performance penalties compared to direct usage, though not explicitly documented.

Frequently Asked Questions

Quick Stats

Stars610
Forks47
Contributors0
Open Issues5
Last commit5 years ago
CreatedSince 2015

Tags

#ios#codable#swift-package-manager#pattern-matching#type-safe#swift#string-manipulation#regular-expressions#macos

Built With

S
Swift

Included in

iOS51.7k
Auto-fetched 16 hours ago

Related Projects

RegexRegex

🔤 Swifty regular expressions

Stars335
Forks16
Last commit10 months ago
RegexRegex

Regular expressions for swift

Stars328
Forks33
Last commit7 years ago
PySwiftyRegexPySwiftyRegex

Easily deal with Regex in Swift in a Pythonic way

Stars229
Forks13
Last commit7 years ago
SwiftRegexSwiftRegex

Perl-like regex =~ operator for Swift

Stars111
Forks12
Last commit9 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub