1.0.14 • Published 6 years ago

vamtiger-regex-leading-dash v1.0.14

Weekly downloads
29
License
MIT
Repository
github
Last release
6 years ago

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';
 * }
 **/
1.0.14

6 years ago

1.0.13

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.2

6 years ago