perl-regex
v1.0.4
Published
Perl regex engine for node.js
Downloads
143
Readme
Perl regex engine for node.js
Binding Perl to enrich the regular expression from node.js, such as look behind assertion.
Requirements
- Perl 5 is needed.
Installation
npm install perl-regex
Examples
- Match using regular expression in string:
let pregex = require('perl-regex');
console.log(pregex.match('EMAIL: [email protected]',
'^email: [a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$',
'i'));
// output:
// true
- Match using
RegExp
object:
let pregex = require('perl-regex');
console.log(pregex.match('EMAIL: [email protected]',
/^email: [a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/i));
// output:
// true
- Exec regular expression in string:
let pregex = require('perl-regex');
console.log(pregex.exec('Great responsibility comes with great power',
'(?<=great )\\w+',
'gi'));
// output:
// [ 'power', 'responsibility', 'power' ]
- Exec
RegExp
object:
let pregex = require('perl-regex');
console.log(pregex.exec('https://127.0.0.1:1314/index.html',
/(https?):\/\/(\d+\.\d+\.\d+\.\d+):(\d+)\/([a-zA-z.]+)/));
// output:
// [ 'https://127.0.0.1:1314/index.html',
// 'https',
// '127.0.0.1',
// '1314',
// 'index.html' ]