root / HServer / 00.Server / 00.Program / node_modules / lodash / deburr.js
이력 | 보기 | 이력해설 | 다운로드 (1.58 KB)
1 | 39 | HKM | var deburrLetter = require('./_deburrLetter'), |
---|---|---|---|
2 | toString = require('./toString');
|
||
3 | |||
4 | /** Used to match Latin Unicode letters (excluding mathematical operators). */
|
||
5 | var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; |
||
6 | |||
7 | /** Used to compose unicode character classes. */
|
||
8 | var rsComboMarksRange = '\\u0300-\\u036f', |
||
9 | reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
||
10 | rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
||
11 | rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange; |
||
12 | |||
13 | /** Used to compose unicode capture groups. */
|
||
14 | var rsCombo = '[' + rsComboRange + ']'; |
||
15 | |||
16 | /**
|
||
17 | * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
|
||
18 | * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
|
||
19 | */
|
||
20 | var reComboMark = RegExp(rsCombo, 'g'); |
||
21 | |||
22 | /**
|
||
23 | * Deburrs `string` by converting
|
||
24 | * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
|
||
25 | * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
|
||
26 | * letters to basic Latin letters and removing
|
||
27 | * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
|
||
28 | *
|
||
29 | * @static
|
||
30 | * @memberOf _
|
||
31 | * @since 3.0.0
|
||
32 | * @category String
|
||
33 | * @param {string} [string=''] The string to deburr.
|
||
34 | * @returns {string} Returns the deburred string.
|
||
35 | * @example
|
||
36 | *
|
||
37 | * _.deburr('déjà vu');
|
||
38 | * // => 'deja vu'
|
||
39 | */
|
||
40 | function deburr(string) { |
||
41 | string = toString(string); |
||
42 | return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); |
||
43 | } |
||
44 | |||
45 | module.exports = deburr; |