vamtiger-regex-leading-dash
TypeScript icon, indicating that this package has built-in type declarations

1.0.14 • Public • Published

VAMTIGER Regex Leading Dash

A regular expression to match leading dash character(s) for a defined input string.

Installation

VAMTIGER Regex Leading Dash can be installed using npm or yarn:

npm i --save vamtiger-regex-leading-dash

or

yarn add vamtiger-regex-leading-dash

Usage

Import or require a referece to VAMTIGER Regex Leading Dash:

import regex from 'vamtiger-regex-leading-dash';

or

const regex = require('vamtiger-regex-leading-dash').default;

VAMTIGER Regex Leading Dash can then be used to test whether a defined input string contains a leading Dash:

import regex from 'vamtiger-regex-leading-dash';

const input = '-SomeInputStringWithALeadingDash';
const match = input.match(regex);

/**
 * if (match) {
 *     // Yep, the input string has a leading dash
 *     match[0] === '-';
 *     match[1] === 'SomeInputStringWithALeadingDash'
 * }
 **/

Named capture groups can be referenced when used together with XRegExp:

import * as XRegExp from 'xregexp';
import {default as regex, Match} from 'vamtiger-regex-leading-dash';
const input = '--SomeInputStringWithALeadingDashes';
const match = XRegExp.exec(input, regex);
// const match: Match = XRegExp.exec(input, regex); // Typescript

/**
 * if (match) {
 *     // Yep, the input string has a leading dashes
 *     match[0] === '--';
 *     match[1] === 'SomeInputStringWithALeadingDash';
 *     match.dash === '--';
 *     match.afterDash === 'SomeInputStringWithALeadingDashes';
 * }
 **/

Package Sidebar

Install

npm i vamtiger-regex-leading-dash

Weekly Downloads

50

Version

1.0.14

License

MIT

Unpacked Size

9.45 kB

Total Files

12

Last publish

Collaborators

  • vamtiger-project