An open API service indexing awesome lists of open source software.

https://github.com/regexhq/es6-template-regex

Regular expression for matching es6 template delimiters in a string.
https://github.com/regexhq/es6-template-regex

es2015 es6 match parse regex regular-expression syntax template

Last synced: 11 months ago
JSON representation

Regular expression for matching es6 template delimiters in a string.

Awesome Lists containing this project

README

          

# es6-template-regex [![NPM version](https://img.shields.io/npm/v/es6-template-regex.svg?style=flat)](https://www.npmjs.com/package/es6-template-regex) [![NPM monthly downloads](https://img.shields.io/npm/dm/es6-template-regex.svg?style=flat)](https://npmjs.org/package/es6-template-regex) [![NPM total downloads](https://img.shields.io/npm/dt/es6-template-regex.svg?style=flat)](https://npmjs.org/package/es6-template-regex) [![Linux Build Status](https://img.shields.io/travis/regexhq/es6-template-regex.svg?style=flat&label=Travis)](https://travis-ci.org/regexhq/es6-template-regex)

> Regular expression for matching es6 template delimiters in a string.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save es6-template-regex
```

## Usage

The main export of this module is a function that must be called:

```js
var regex = require('es6-template-regex');
console.log(regex());
```

## Example

```js
function interpolate(str, data) {
return str.replace(re(), function(m, prop) {
return data[prop] || prop;
});
}

var str = 'foo ${bar} baz ${quux}';
var data = {bar: 'AAA', quux: 'BBB'};
interpolate(str, data);
//=> 'foo AAA baz BBB'
```

## About

### Related projects

* [to-regex-range](https://www.npmjs.com/package/to-regex-range): Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than… [more](https://github.com/micromatch/to-regex-range) | [homepage](https://github.com/micromatch/to-regex-range "Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than 2.78 million test assertions.")
* [unc-path-regex](https://www.npmjs.com/package/unc-path-regex): Regular expression for testing if a file path is a windows UNC file path. Can… [more](https://github.com/regexhq/unc-path-regex) | [homepage](https://github.com/regexhq/unc-path-regex "Regular expression for testing if a file path is a windows UNC file path. Can also be used as a component of another regexp via the `.source` property.")
* [whitespace-regex](https://www.npmjs.com/package/whitespace-regex): Regular expression for matching the whitespace in a string. | [homepage](https://github.com/regexps/whitespace-regex "Regular expression for matching the whitespace in a string.")

### Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

### Contributors

| **Commits** | **Contributor** |
| --- | --- |
| 7 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [adjohnson916](https://github.com/adjohnson916) |

### Building docs

_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

### Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

```sh
$ npm install && npm test
```

### Author

**Jon Schlinkert**

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)

### License

Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 07, 2017._