1.0.3 • Published 7 years ago

regexallmatches v1.0.3

Weekly downloads
5
License
ISC
Repository
github
Last release
7 years ago

(⚫➕❓) regexAllMatches

Donate

regexAllMatches is a simple module that works to get all matches of a regular expression

◼ Installation

npm install regexallmatches --save

📋 Usage

regexAllMatches(string, regex);

Params

  • string - String to which matches will be searched
  • regex - Regex object or a string with a valid regex expression
const regexAllMatches = require("regexallmatches");

regexAllMatches("planir", /^[a-z0-9_-]{3,16}$/);

/** =>
 * {
 *     regex: /^[a-z0-9_-]{3,16}$/, 
 *     string: 'planir',
 *     groups: {'0': [ 'planir' ]}
 * }
 */
 
// Multiple matches
regexAllMatches("uno dos tres", /[a-z]+/g)

/** =>
 * {
 *     regex: /[a-z]+/g, 
 *     string: 'uno dos tres',
 *     groups: { '0': [ 'uno', 'dos', 'tres' ] }
 * }
 */ 
 
 /**
 * Digits allowed to username
 * @var Number between_digits
 */
var between_digits = "3,16";

// You can pass a string on the second argument and a third argument in the function to indicate the flags
regexAllMatches("marcos8", '^[a-z0-9_-]{' + between_digits + '}$', 'g').groups);

// => { '0': [ 'marcos8' ] }

💖 Donations

Soon I will be creating other modules that will help them improve their code, I would really appreciate it if they helped me by donating

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago