Git Product home page Git Product logo

regulate's Introduction

Regulate

Regulate is a library for generating regular expressions in JavaScript code. It grew out of the need for a tool that would allow non-technical users to build up regular expressions for reporting purposes.

It's built on Node but runs pretty much anywhere. To use it in your own projects you can install it via npm:

npm install regulate

Or just include the script in your page:

<script src="Regulate.min.js"></script>

To build the minified script yourself simply clone the repository and run the Grunt build script to generate a build directory in the project root. Please note that you will need Grunt 0.4 at least:

grunt uglify

Usage

Regulate exposes a single global function, Regulate. It's effectively a factory function that returns an instance. Almost all of the Regulate instance methods return the same instance to allow for chaining. Here's a simple example that builds a regular expression to match a 3-16 character "username" made up of lower-case characters, underscores and digits:

var rxUser = Regulate().start().charIn(["a", "z"], [0, 9], "_").repeat(3, 16).end();
rxUser.toString(); // '^[a-z0-9_]{3, 16}$'

For details of all the available methods have a look at the API.

Contributing

If you would like to contribute to Regulate please have a look at the contribution guidelines. You'll need Grunt 0.4 or above to develop Regulate locally. Thanks, and we look forward to your patches!

Licence

Regulate is distributed under the MIT License. See the LICENSE file for the full licence text. Copyright © 2013 Global Personals, Ltd.

regulate's People

Watchers

Inno 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.