Giter Club home page Giter Club logo

regextester's Introduction

RegexTester

A simple Mac app for making Swift regex patterns.

Screenshot of app showing a matched Git log

Regex is displayed in a "normal" text field, above, so that you can edit it easily, and below it is an "escaped" text field. These fields mirror each other as you go.

The opts button allows you to toggle all the options in the NSRegularExpression.Options option set, and copy produces:

let regexStr = "commit ([0-9a-f]{40}).*?(Merge: [0-9a-f ]{15}\\n)?\\nAuthor: (.*?)\\nDate:   (.*?)\\n(.*?\\n\\n)"
let regex = try? NSRegularExpression(pattern: regexStr, options: [.dotMatchesLineSeparators])

which you can paste into your code and mod at will.*

Attribution

Written by Steve Sparks (@barbecuesteve), engineer at Big Nerd Ranch. Screenshot shows a portion of the git log of BNR's Deferred library.

Known Issues

Some expressions can cause the beachball of death due to catastrophic backtracking. No attempt is taken to limit the greediness of your expression. You've been warned. Kill it and restart it.

Contributing

Please do! Open a pull request.

--

*Personally I do it this way. It is more maintainable.

extension NSRegularExpression {

    enum Regex: String {
        case gitLogEntry = "commit ([0-9a-f]{40}).*?(Merge: [0-9a-f ]{15}\n)?\nAuthor: (.*?)\nDate: (.*?)\n\n(.*?)\n\n"
    }

    convenience init(regex: Regex, options: NSRegularExpression.Options) throws {
        try self.init(pattern: regex.rawValue, options: options)
    }
}

let myRegex = try NSRegularExpression(regex: .gitLogEntry, options: [.dotMatchesLineSeparators])

regextester's People

Contributors

stevesparks avatar

Stargazers

Pavel avatar haozes avatar GeumSang Yoo avatar Håkon Bogen avatar Mark Anderson avatar Jared Sinclair avatar Chris Morris avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.