---
title: RegexBuilder
framework: RegexBuilder
role: collection
role_heading: Framework
platforms: [iOS 16.0+, iPadOS 16.0+, Mac Catalyst 16.0+, macOS 13.0+, tvOS 16.0+, watchOS 9.0+]
path: regexbuilder
---

# RegexBuilder

Use an expressive domain-specific language to build regular expressions, for operations like searching and replacing in text.

## Overview

Overview Regular expressions, also known as regexes, are a powerful tool for matching patterns in text. Swift supports several ways to create a regular expression, including from a string, as a literal, and using this DSL. For example: let word = OneOrMore(.word) let emailPattern = Regex {     Capture {         ZeroOrMore {             word             "."         }         word     }     "@"     Capture {         word         OneOrMore {             "."             word         }     } }

let text = "My email is my.name@example.com." if let match = text.firstMatch(of: emailPattern) {     let (wholeMatch, name, domain) = match.output     // wholeMatch is "my.name@example.com"     // name is "my.name"     // domain is "example.com" }

## Topics

### Components

- [CharacterClass](regexbuilder/characterclass.md)
- [Anchor](regexbuilder/anchor.md)
- [Lookahead](regexbuilder/lookahead.md)
- [NegativeLookahead](regexbuilder/negativelookahead.md)
- [ChoiceOf](regexbuilder/choiceof.md)

### Quantifiers

- [One](regexbuilder/one.md)
- [Optionally](regexbuilder/optionally.md)
- [ZeroOrMore](regexbuilder/zeroormore.md)
- [OneOrMore](regexbuilder/oneormore.md)
- [Repeat](regexbuilder/repeat.md)
- [Local](regexbuilder/local.md)

### Captures

- [Capture](regexbuilder/capture.md)
- [TryCapture](regexbuilder/trycapture.md)
- [Reference](regexbuilder/reference.md)

### Builders

- [RegexComponentBuilder](regexbuilder/regexcomponentbuilder.md)
- [AlternationBuilder](regexbuilder/alternationbuilder.md)

### Operators

- [...(_:_:)](regexbuilder/'...(_:_:)-16g2a.md)
- [...(_:_:)](regexbuilder/'...(_:_:)-629xh.md)
