vamtiger-regex-leading-dash
v1.0.14
Published
Matches a string with leading dash(es).
Downloads
250
Maintainers
Readme
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';
* }
**/