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.
- Host: GitHub
- URL: https://github.com/regexhq/es6-template-regex
- Owner: regexhq
- License: mit
- Created: 2015-08-11T02:00:37.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-07-01T21:34:29.000Z (almost 9 years ago)
- Last Synced: 2024-11-01T04:52:05.119Z (over 1 year ago)
- Topics: es2015, es6, match, parse, regex, regular-expression, syntax, template
- Language: JavaScript
- Size: 9.77 KB
- Stars: 16
- Watchers: 12
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# es6-template-regex [](https://www.npmjs.com/package/es6-template-regex) [](https://npmjs.org/package/es6-template-regex) [](https://npmjs.org/package/es6-template-regex) [](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._