Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Generate RegExp for delimiters, to be used with templates, files or data streams.
Generate RegExp for delimiters, to be used with templates, files or data streams.
To install the module with npm, run the following in the command line:
npm i delims --save
To install with bower, run:
bower install delims --save
Use within your application with the following line of JavaScript:
var delims = require('delims');
delims([delimiters], {options});
Type: Array
Default: ['---', '---']
An array of strings is appropriate for typical use cases, with the first item in the array being the "opening" delimiter, and the second item being the "closing" delimiter. In cases when multiple delimiters are required, e.g. ---
or ~~~
, an array of arrays may be passed in, where the first array will be used as opening delimiters and the second array will be used as closing delimiters.
Additionally, when multiple arrays are passed in the generated delimiters will be wrapped in non-capturing RegExp groups. For example, this:
delims([
['---', '~~~'], // delimiter 1
['---', '~~~'] // delimiter 2
]);
will result in something like this:
// for clarity, only the regex for delimiters is shown here
(?:---|~~~)/*other regex*/(?:---|~~~)
(Warning! Passing in multiple delimiters is a good way to cause delimiter collision, you best avoid doing so accept for running tests. Don't say I didn't warn you!)
An object of options may be passed as a second parameter. Example:
delims(['---', '---'], options);
Here are the available options and their defaults, starting with boundary options:
In addition to the delimiters themselves, these additional boundary options are available for increased flexibility.
Type: Boolean
Default: ([\s\S]+?)
This is the "content" between the delimiters. YAML Front Matter being the inspiration for matter
. See the examples.
Type: Boolean
Default: ([\s\S]+|\s?)
The "content" after the delims
Type: Boolean
Default: ^
^
Matches beginning of input. See the Mozilla RegEx documentation.
Type: Boolean
Default: $
$
Matches end of input. See the Mozilla RegEx documentation.
Type: Boolean
Default: false
Escape custom regex used for delimiters. E.g. ['{%', '%}']
will be escaped to ['\\{\\%', '\\%\\}']
before being passed to new RegExp()
.
Type: Boolean
Default: false
Build a non-capture group. Disabled by default, but enabled by default when multiple delimiters are passed in.
Type: Boolean
Default: undefined
g
: global matchi
: ignore casem
: multiline, so that beginning and end characters, ^
and $
, work over multiple lines. See the Mozilla RegEx documentation.A delimiter is a sequence of one or more characters used to specify the boundary between separate, independent regions in plain text or other data streams. --Wikipedia
Jon Schlinkert
Copyright (c) 2014 Jon Schlinkert, contributors. Released under the MIT license
FAQs
Generate RegExp for delimiters, to be used with templates, files or data streams.
The npm package delims receives a total of 3,257 weekly downloads. As such, delims popularity was classified as popular.
We found that delims demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.