Skip to content

Wrapper class for NSRegularExpression in Swift 3.0.

License

Notifications You must be signed in to change notification settings

SkrewEverything/Regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Regex

Wrapper class for NSRegularExpression in Swift.

Swift 3.0

Usage

Regex(regex:string:) First argument takes regular expression and second argument takes a string to be checked.

getMatchedResults() returns an optional String array of matched strings.

getCapturedGroups() returns an optional String array of captured groups.

Example

let a        = Regex(regex: "(\\D+)\\s(\\D+)", string: "Mom's Spaghetti")
let matched  = a.getMatchedResults() // matched strings
let captured = a.getCapturedGroups() // grouped strings

// Iterating over matched strings
if let result = matched 
{
    for r in result
    {
        print(r)
    }
}

// Iterating over captured groups
if let result = captured
{
    for r in result
    {
        print(r)
    }
}

License

MIT

Free Software, Hell Yeah!

About

Wrapper class for NSRegularExpression in Swift 3.0.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages