ptm-multiregexp
v0.0.2
Published
Multi RegExp
Readme
Multi RegExp
About
Use multiple RegExp like you had only one ! Iterate on matches or find the first match.
[!NOTE] This is extends from multiregexp
Install and Use
Install from npm
npm i ptm-multiregexppnpm i ptm-multiregexpyarn add ptm-multiregexpImport
import MultiRegExp from "ptm-multiregexp"; //esm
import MultiRegExp = require("ptm-multiregexp"); // typescript cjsconst MultiRegExp = require("ptm-multiregexp"); // cjsInstall from jsr.io
deno
deno add jsr:@ptm/multiregexpImport symbol
import * as multiregexp from "@ptm/multiregexp";Import directly with a jsr specifier
import * as multiregexp from "jsr:@ptm/multiregexp";npm
npx jsr add @ptm/multiregexpImport symbol
import * as multiregexp from "@ptm/multiregexp";yarn
yarn add jsr:@ptm/multiregexpUsing Yarn 4.8 or older
yarn dlx jsr add @ptm/multiregexpImport symbol
import * as multiregexp from "@ptm/multiregexp";pnpm
pnpm i jsr:@ptm/multiregexpUsing pnpm 10.8 or older
pnpm dlx jsr add @ptm/multiregexpImport symbol
import * as multiregexp from "@ptm/multiregexp";Example
const regexp = /(#{1,6})[ ]+(.*)/g;
const string = "## Hello World";
const multiregexp = new MultiRegExp([regexp]);
const result = multiregexp.getMatched(string);
/*
match: "## Hello World",
start: 0,
end: 14,
groupCount: 2,
group_1: "##",
group_2: "Hello World",
*/