Regex by brynbellomy alternatives and similar libraries
Based on the "Text" category.
Alternatively, view Regex by brynbellomy alternatives based on common mentions on social networks and blogs.
-
PhoneNumberKit
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. -
SwiftRichString
👩🎨 Elegant Attributed String composition in Swift sauce -
TwitterTextEditor
A standalone, flexible API that provides a full-featured rich text editor for iOS applications. -
RichEditorView
RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing. -
TextAttributes
An easier way to compose attributed strings -
edhita
Fully open source text editor for iOS written in SwiftUI. -
SwiftString
A comprehensive, lightweight string extension for Swift -
SwiftyAttributes
A Swifty API for attributed strings -
Atributika
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement. -
Notepad
[iOS] A fully themeable markdown editor with live syntax highlighting. -
MarkdownKit
A simple and customizable Markdown Parser for Swift -
Mustard
🌭 Mustard is a Swift library for tokenizing strings when splitting by whitespace doesn't cut it. -
SwiftVerbalExpressions
Swift Port of VerbalExpressions -
PrediKit
An NSPredicate DSL for iOS, OSX, tvOS, & watchOS. Inspired by SnapKit and lovingly written in Swift. -
AttributedTextView
Easiest way to create an attributed UITextView (with support for multiple links and from html) -
Apodimark
Fast, flexible markdown parser written in Swift -
Regex by crossroadlabs
Regular expressions for swift -
Regex by sindresorhus
🔤 Swifty regular expressions -
PySwiftyRegex
Easily deal with Regex in Swift in a Pythonic way -
OysterKit
OysterKit is a framework that provides a native Swift scanning, lexical analysis, and parsing capabilities. In addition it provides a language that can be used to rapidly define the rules used by OysterKit called STLR -
Tagging
A TextView that provides easy to use tagging feature for Mention or Hashtag -
PredicateFlow
Write amazing, strong-typed and easy-to-read NSPredicate. -
OEMentions
An easy way to add mentions to uitextview like Facebook and Instagram -
SmarkDown
A Pure Swift implementation of the markdown mark-up language -
Veneer
A simple library for building attributed strings, for a more civilized age.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Regex by brynbellomy or a related project?
README
Regex.swift
install
Use CocoaPods.
Add to your Podfile
:
pod 'Regex'
And then run pod install
from the shell:
$ pod install
usage
Simple use cases: String
extension methods
String.grep()
This method is modeled after Javascript's String.match()
. It returns a Regex.MatchResult
object. The object's captures
property is an array of String
s much as one would expect from its Javascript equivalent.
let result = "Winnie the Pooh".grep("\\s+([a-z]+)\\s+")
result.searchString == "Winnie the Pooh"
result.captures.count == 2
result.captures[0] == " the "
result.captures[1] == "the"
result.boolValue == true // `boolValue` is `true` if there were more than 0 matches
// You can use `grep()` in conditionals because of the `boolValue` property its result exposes
let emailAddress = "bryn&typos.org"
if !emailAddress.grep("@") {
// that's not an email address!
}
String.replaceRegex()
This method is modeled after the version of Javascript's String.replace()
that accepts a Regex parameter.
let name = "Winnie the Pooh"
let darkName = name.replaceRegex("Winnie the ([a-zA-Z]+)", with: "Darth $1")
// darkName == "Darth Pooh"
Advanced use cases: Regex
object and operators
operator =~
You can use the =~
operator to search a String
(the left operand) for a Regex
(the right operand). It's the same as calling theString.grep("the regex pattern")
, but might be more clear in some cases. It returns the same Regex.MatchResult
object as String.grep()
.
"Winnie the Pooh" =~ Regex("\\s+(the)\\s+") // returns a Regex.MatchResult
Quickly loop over a Regex
's captures:
for capture in ("Winnie the Pooh" =~ Regex("\\s+(the)\\s+")).captures {
// capture is a String
}
Overriden map()
function for substitution
A more "functional programming" way of doing string replacement is possible via an override for map()
. In keeping with the overall aim to avoid reinventing a perfectly good wheel (i.e., NSRegularExpression
), this function simply calls through to NSRegularExpression.replaceMatchesInString()
.
func map (regexResult:Regex.MatchResult, replacementTemplate:String) -> String
You can use it like so:
let stageName = map("Winnie the Pooh" =~ Regex("([a-zA-Z]+)\\s+(the)(.*)"), "$2 $1")
// stageName == "the Winnie"
Or if you have some functional operators lying around (for example: https://github.com/brynbellomy/Funky), it's a little less wordy:
("Winnie the Pooh" =~ Regex("([a-zA-Z]+)\\s+(the)(.*)")) |> map‡("$2 $1")
... but you have to be as crazy as me to find that more readable than "Winnie".replaceRegex(_:withString:)
, so no pressure.
contributors / authors
- bryn austin bellomy ([email protected])