Finds text that matches a regular expression in the browser. Allows content to be changed with a callback function.
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
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));
None
- typescript: TypeScript is a language for application scale JavaScript development