Swift Regex Tester & Builder
Test regex patterns in real-time, inspect capture groups, and generate modern Swift 5.7+ /.../ regex literals or Foundation NSRegularExpression code.
// Swift 5.7+ Regex Literal
let regex = /[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,64}/
let text = """
Contact us at support@thorous.com or alex.dev@example.org for details.
"""
for match in text.matches(of: regex) {
print("Matched: \(match.output)")
}// Foundation NSRegularExpression
let pattern = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
let regex = try NSRegularExpression(
pattern: pattern,
options: [.caseInsensitive]
)
let nsString = text as NSString
let results = regex.matches(in: text, range: NSRange(location: 0, length: nsString.length))
let matches = results.map { nsString.substring(with: $0.range) }Regular Expressions in Modern Swift
Compile-Time Regex Checking
Since Swift 5.7 and iOS 16, regex literals wrapped in slashes (/pattern/) are parsed and verified at compile-time by the Swift compiler.
Strongly Typed Captures
Named and numbered capture groups output strongly-typed tuples directly rather than error-prone string index ranges.
RegexBuilder DSL
Apple’s declarative RegexBuilder framework allows constructing complex patterns using SwiftUI-like syntax blocks for maximum readability.
Build full iPhone apps without touching Xcode
Enjoying this free Regex Tester? Thorous turns your natural language prompts into compiled native SwiftUI apps, with real-time iOS simulator streaming and visual on-screen editing.
Native Mac app · macOS 14 Sonoma or later · Apple silicon & Intel