Skip to content

A small node.js module that helps to find strings containing diacritics with regular expressions. Useful for accentued search in MongoDB.

License

Notifications You must be signed in to change notification settings

valudio/diacritic-regex-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

diacritic-regex-helper

A small node.js module that helps to find strings containing diacritics with regular expressions. Useful for accentued search in MongoDB.

NPM

Installation

$ npm install diacritic-regex-helper

Usage

JS :

var diacriticHelper = require("diacritic-regex-helper");

var toFind = "noel";
var txt = "Vive le Père-Noël !";

// Without diactric-helper
var result1 = txt.replace(new RegExp("noel","gi"), "Fouettard")
console.log(result1);

// With diactric-helper
var result2 = txt.replace(new RegExp(diacriticHelper(toFind),"gi"), "Fouettard")
console.log(result2);

Console output :

Vive le Père-Noël !
Vive le Père-Fouettard !

MIT Licensed

Disclaimer

This package is exactly the same as this one by steevelefort. For some reason it was making Meteor apps to throw an error so I decided to publish it again and now it's working ok. All the credit goes to steevelefort.

About

A small node.js module that helps to find strings containing diacritics with regular expressions. Useful for accentued search in MongoDB.

Resources

License

Stars

Watchers

Forks

Packages

No packages published