Giter VIP home page Giter VIP logo

regexp-tpl's Introduction

regexp-tpl

regexp-tpl allows you to create templated regular expressions.

NPM version Build status Dependency Status devDependency Status Coverage Status Code Climate Package Quality Dependency Status

Installation

First install regexp-tpl in you project:

npm install --save regexp-tpl

Getting started

Then, use it:

const regexpTpl = require('regexp-tpl');
const assert = require('assert');

const fruits = [{
  name: 'orange',
  count: 2,
  colors: ['orange'],
}, {
	name: 'banana',
  count: 0,
  colors: ['yellow', 'white'],
}, {
	name: 'kiwi',
  count: 8,
  colors: ['brown', 'green'],
}];

assert(regexpTpl(fruits, 'My car is {colors.#}!').test('My car is brown!'));
assert(!regexpTpl(fruits, 'My car is {colors.#}!').test('My car is blue!'));

Note that regexp-tpl template values are evaluated with miniquery's syntax.

## API

### regExp:RegExp regexpTpl(objs:Array, regExpTemplate:String, regExpflags:String, tplRegExp:RegExp) Return a RegExp instance made with the given regExpTemplate and regExplags filled with the values picked up in the given objs. An optionnal tplRegExp value can be provided for custom template syntax.

Contribute

Feel free to submit us your improvements. To do so, you must accept to publish your code under the MIT license.

To start contributing, first run the following to setup the development environment:

git clone [email protected]:SimpliField/regexp-tpl.git
cd regexp-tpl
npm install

Then, run the tests:

npm test

Stats

NPM NPM

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.