Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A Swift μframework providing an NSRegularExpression-backed Regex type

License

Notifications You must be signed in to change notification settings

SwiftResourceCollection/Regex

Repository files navigation

Regex

Pattern match like a boss.

Usage

Create:

let greeting = Regex("hello (world|universe)")
let magic: Regex = "(.*)"

Match:

if greeting.matches("hello universe!") {
 print("wow, you're friendly!")
}

Pattern match:

switch someTextFromTheInternet {
case Regex("DROP DATABASE (.+)"):
 // TODO: patch security hole
default:
 break
}

Capture:

let greeting: Regex = "hello (world|universe|swift)"
if let subject = greeting.match("hello swift")?.captures[0] {
 print("ohai \(subject)")
}

Installation

Carthage

Put this in your Cartfile:

github "sharplet/Regex"

CocoaPods

Put this in your Podfile:

pod "Regex", git: "https://github.com/sharplet/Regex.git"

About

A Swift μframework providing an NSRegularExpression-backed Regex type

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 88.1%
  • Ruby 8.9%
  • Objective-C 3.0%

AltStyle によって変換されたページ (->オリジナル) /