replace-element
v1.1.0
Published
Finds text that matches a regular expression in the browser. Allows content to be changed with a callback function.
Downloads
27
Readme
replace-element
Finds text that matches a regular expression in the browser. Allows content to be changed with a callback function.
Installation
Download node at nodejs.org and install it, if you haven't already.
npm install replace-element --save
This package is provided in these module formats:
- CommonJS
TL-DR
const { replaceElement } = require('../dist/index');
const { cpf, cnpj } = require('cpf-cnpj-validator');
const CpfCnpjRegex = /(\d{3}\.\d{3}\.\d{3}\-\d{2})|(\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2})/g;
replaceElement(CpfCnpjRegex, (payload, element) => {
/* callback */
element.style.color = "red";
element.style.fontWeight = "bold";
element.onclick = function () { alert(payload); }
}, (payload) => cpf.isValid(payload) || cnpj.isValid(payload));
Dependencies
None
Dev Dependencies
- typescript: TypeScript is a language for application scale JavaScript development