steevelefort / diacritic-helper

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Diacritic-helper

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

Installation

$ npm install diacritic-helper

Usage

JS :

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

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

// Without diactric-helper
var result1 = txt.replace(new RegExp(toFind,"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 !

About

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


Languages

Language:JavaScript 100.0%