Skip to content

Generate template delimiters for string interpolation.

License

Notifications You must be signed in to change notification settings

regexhq/delimiter-regex

 
 

Repository files navigation

delimiter-regex NPM version Build Status

Create regex for template delimiters.

Install with npm

npm i delimiter-regex --save

Usage

var delims = require('delimiter-regex');

Example:

Get a regex for matching front-matter:

delims('---', '---');
//=> /---\s*([\s\S]*?)\s*---/

If no args are passed, es6 delimiter regex is returned:

delims();
//=> /\$\{\s*([\s\S]*?)\s*\}/

Params

  • delimiters {String|Array}: supports array format (delims(['{{', '}}'])) or list (delims('{{', '}}'))
  • options: currently RegExp flags is the only option

Flags example

delims('{{', '}}', {flags: 'gm'});
//=> /\{\{([^}}]*)\}\}/gm

Running tests

Install dev dependencies.

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2014-2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on March 18, 2015.

About

Generate template delimiters for string interpolation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%