1. regex-match-all
PHP-like regex match all
regex-match-all
Package: regex-match-all
Created by: newtoncodes
Last modified: Sun, 26 Jun 2022 10:43:03 GMT
Version: 1.0.2
License: MIT
Downloads: 11,674
Repository: https://github.com/newtoncodes/regex-match-all

Install

npm install regex-match-all
yarn add regex-match-all

regex-match-all

PHP-like regex match all

Installation

npm install --save regex-match-all

The UMD build is in the dist directory.

Can be used both in node and browser.

Usage

 'use strict';

const RegEx = require('../src/RegEx.js');

let text = 'asd12 dsa asd23 dsa asd34 dsa';

console.log(JSON.stringify(
    
    RegEx.matchAll(/asd(\d)(\d)/g, text)
    
, null, 4));

/*
[
    [
        "asd12",
        "asd23",
        "asd34"
    ],
    [
        "1",
        "2"
    ],
    [
        "2",
        "3"
    ],
    [
        "3",
        "4"
    ]
]
*/

console.log(JSON.stringify(
    
    RegEx.matchAll(/asd(\d)(\d)/g, text, RegEx.REGEXP_PATTERN_ORDER)
    
, null, 4));

/*
    Same as above
*/

console.log(
    
    JSON.stringify(RegEx.matchAll(/asd(\d)(\d)/g, text, RegEx.REGEXP_SET_ORDER)
    
, null, 4));

/*
[
    [
        "asd12",
        "1",
        "2"
    ],
    [
        "asd23",
        "2",
        "3"
    ],
    [
        "asd34",
        "3",
        "4"
    ]
]
*/

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code