Latest 2.0.0
Homepage https://github.com/Meniny/ColaExpression
License MIT
Platforms ios 9.0, osx 10.11, tvos 9.0, watchos 3.0
Frameworks Foundation
Authors

ColaExpression

VersionAuthorBuild PassingSwift
PlatformsMIT
CocoapodsCarthageSPM


What’s this?

ColaExpression is a Cross-Platform Regular Expression Library written in Swift.

Requirements

  • iOS 9.0+
  • macOS 10.10+
  • watchOS 3.0+
  • tvOS 9.0+
  • Xcode 8 with Swift 3

Installation

CocoaPods

pod 'ColaExpression'

Contribution

You are welcome to fork and submit pull requests.

License

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

Usage

isMatch() -> Bool

let pattern = "[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,6}"
let str = "[email protected]"
let cola = ColaExpression(pattern)
if cola.isMatch(with: str) {
  print("(str) is a valid email")
  // [email protected] is a valid email
}
if str.isMatch(pattern: pattern) {
  print("(str) is a valid email")
  // [email protected] is a valid email
}

matches() -> [String]

let pattern = "[a-z]{3}"
let str = "AAAbbbCCCdddEEEfff"
let cola = ColaExpression(pattern)
let matches = cola.matches(of: str)
// ["bbb", "ddd", "fff"]
let matches = str.matches(pattern: pattern)
// ["bbb", "ddd", "fff"]

replaceOccurences() -> String

let pattern = "[a-z]"
let str = "AAAbbbCCCdddEEEfff"
let replacement = "-"
let cola = ColaExpression(pattern)
let replaced = cola.replaceOccurences(in: str, with: replacement)
// AAA---CCC---EEE---
let replaced = str.replaceOccurences(matches: pattern, with: replacement)
// AAA---CCC---EEE---

Latest podspec

{
    "name": "ColaExpression",
    "version": "2.0.0",
    "summary": "A Cross-Platform Regular Expression Library written in Swift.",
    "description": "ColaExpression is a Cross-Platform Regular Expression Library written in Swift.",
    "homepage": "https://github.com/Meniny/ColaExpression",
    "license": "MIT",
    "authors": {
        "Meniny": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Meniny/ColaExpression.git",
        "tag": "2.0.0"
    },
    "social_media_url": "http://meniny.cn/",
    "platforms": {
        "ios": "9.0",
        "osx": "10.11",
        "tvos": "9.0",
        "watchos": "3.0"
    },
    "source_files": "ColaExpression/**/*.*",
    "public_header_files": "ColaExpression/*{.h}",
    "frameworks": "Foundation",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This