Skip to content

Finds text that matches a regular expression in the browser. Allows content to be changed with a callback function.

Notifications You must be signed in to change notification settings

lfamorim/replace-element

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

replace-element

npm version minzipped size

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

License

MIT

About

Finds text that matches a regular expression in the browser. Allows content to be changed with a callback function.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 83.2%
  • JavaScript 16.8%