How to use the deburr function from lodash

Find comprehensive JavaScript lodash.deburr code examples handpicked from public code repositorys.

lodash.deburr is a lodash utility function that removes diacritical marks from a given string.

183
184
185
186
187
188
189
190
191
192

getSortedBrews : function(brews){
	const testString = _.deburr(this.state.filterString).toLowerCase();

	brews = _.filter(brews, (brew)=>{
		const brewStrings = _.deburr([
			brew.title,
			brew.description,
			brew.tags].join('\n')
			.toLowerCase());
fork icon293
star icon852
watch icon36

+ 29 other calls in file

75
76
77
78
79
80
81
82
83
84
module.exports.curryRight          = _.curryRight;
module.exports.curryRight2         = _.curryRight2;
module.exports.curryRight3         = _.curryRight3;
module.exports.cycle               = _.cycle;
module.exports.debounce            = _.debounce;
module.exports.deburr              = _.deburr;
module.exports.dec                 = _.dec;
module.exports.defaults            = _.defaults;
module.exports.defaultsDeep        = _.defaultsDeep;
module.exports.defer               = _.defer;
fork icon19
star icon122
watch icon0

+ 92 other calls in file

How does lodash.deburr work?

lodash.deburr is a function that removes diacritics from a string by replacing them with their ASCII equivalents. For example, it would convert the character é to e.

790
791
792
793
794
795
796
797
798
799
800
801
802
console.log(camelCase); // => 'fooBar'


const capitalize = _.capitalize('FRED');
console.log(capitalize); // => 'Fred'


const deburr = _.deburr('déjà vu');
console.log(deburr); // => 'deja vu'


const endsWith = _.endsWith('abc', 'c');
console.log(endsWith); // => true
fork icon0
star icon4
watch icon0

+ 15 other calls in file

39
40
41
42
43
44
45
46
47
48
49
50
51


  return {nomNaissance: words.join(' ')}
}


function normalizeStr(str) {
  return deburr(str).toUpperCase().replace(/[^A-Z]/g, ' ').replace(/\s+/g, '-')
}


function computeId({nomNaissance, prenom, dateNaissance, sexe}) {
  return `${dateNaissance}@${sexe}@${normalizeStr(nomNaissance)}@${normalizeStr(prenom)}`
fork icon0
star icon1
watch icon0

Ai Example

1
2
3
4
5
6
const _ = require("lodash");

const accentedString = "Café en Grève";
const deburredString = _.deburr(accentedString);

console.log(deburredString); // Output: Cafe en Greve

In this example, lodash.deburr is used to remove any accent marks from the accentedString variable and return the new, unaccented string as deburredString. The resulting string is printed to the console using console.log.

236
237
238
239
240
241
242
243
244
245
let cleanFormComponentKeys = function(then) {
  // Check each given component key for validity.
  let matches = function(item, changes, uniques) {
    let _old = item;

    item = _.deburr(item);
    item = item.replace(removeRegex, '');
    let valid = item.match(validRegex);

    while (!item || !valid || item.match(invalidRegex) || (uniques.indexOf(item) !== -1)) {
fork icon0
star icon0
watch icon0

Other functions in lodash

Sorted by popularity

function icon

lodash.get is the most popular function in lodash (7670 examples)