Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/meniny/re

🔫 Pythonic RegEx library.
https://github.com/meniny/re

python pythonic re regex regexp regular-expression swift

Last synced: 15 days ago
JSON representation

🔫 Pythonic RegEx library.

Awesome Lists containing this project

README

        

= Meet `re`

++++





Version
Author
Build Passing
Swift


Platforms
MIT


Cocoapods
Carthage
SPM


++++

== 🏵 Introduction

**re**, a tiny Pythonic RegEx library.

Learn more about link:https://docs.python.org/2/library/re.html[re module in Python 2.x].

== 📋 Requirements

- iOS 8.0+
- macOS 10.9+
- tvOS 9.0+
- watchOS 2.0+
- Xcode 9.0+ with Swift 4.1+

== 📲 Installation

`re` is available on link:https://cocoapods.org[CocoaPods].

[source, ruby]
----
use_frameworks!
pod 're'
----

== ❤️ Contribution

You are welcome to fork and submit pull requests.

== 🔖 License

`re` is open-sourced software, licensed under the `MIT` license.

== 🔫 Usage

[source, swift]
----
import re

let string: String = ...
let pattern: String = ...
----

[source, swift]
----
// Swiftly
let regex = RegularExpression.of(pattern)

let matches = regex.matches(in: string)
let groups1 = regex.groups(matches: string)
let groups2 = regex.groups(matches: string, at: 1)
let groups3 = regex.groups(matches: string, at: [1, 2])
let split = regex.split(string)
let replace = regex.replace(with: "BEING_REPLACED", in: string)
----

[source, swift]
----
// Pythonic
let _ = re.compile(pattern, flags: [])

let _ = re.search(pattern, string)
let _ = re.match(pattern, string)
let _ = re.split(pattern, string)
let _ = re.sub(pattern, string)
// ...
----