šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

re-template-tag

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

re-template-tag

This package provides the template tag `re` for composing regular expressions.

2.0.1
latest
Source
npm
Version published
Weekly downloads
4.5K
-40.47%
Maintainers
1
Weekly downloads
Ā 
Created
Source

re-template-tag: easily compose regular expressions

This package provides the template tag re for composing regular expressions.

Basic syntax

Syntax: the following two expressions produce the same regular expression.

re`/abc/gu`
/abc/gu

Composing regular expressions

import {re} from 're-template-tag';

const RE_YEAR = /([0-9]{4})/;
const RE_MONTH = /([0-9]{2})/;
const RE_DAY = /([0-9]{2})/;
const RE_DATE = re`/^${RE_YEAR}-${RE_MONTH}-${RE_DAY}$/u`;

RE_DATE.test('2017-01-23'); // true

More information

  • Take a look at the unit tests.
  • Check out the blog post on re-template-tag.

Acknowledgement

The syntax for separating flags from the actual regular expression is based on an idea by Mathias Bynens.

FAQs

Package last updated on 05 Aug 2017

Did you know?

Socket

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.

Install

Related posts