Powerful string matching insensitive to diacritics, special characters, symbols and case.
npm install shoetest --save
var shoetest = require('shoetest');
var a = 'heļlṏ, wɵrḻɖ!';
var b = 'Algæ Britannicæ';
var c = 'The Crème de la Crème de la Crème!';
shoetest.test('hello world', a);
// -> true
shoetest.test('hello world', [a, b, c]);
// -> true
shoetest.match('Helló (wơrLd)', a);
// -> [ 'heļlṏ, wɵrḻɖ' ]
shoetest.match('algae britannicae', b);
// -> [ 'Algæ Britannicæ' ]
shoetest.match('creme', c);
// -> [ 'Crème', 'Crème', 'Crème' ]
shoetest.replace('creme', '<b>$1</b>', c);
// -> 'The <b>Crème</b> de la <b>Crème</b> de la <b>Crème</b>!'
shoetest.replace('creme', 'Crème fraîche', [a, b, c]);
// -> [ 'heļlṏ, wɵrḻɖ!', 'Algæ Britannicæ', 'The Crème fraîche de la Crème fraîche de la Crème fraîche!' ]
shoetest.simplify('Ƀuffalỗ buḟḟaḻở Ḅuƒfalo ḅuffȃlỗ buffalȏ bǖffaḻồ Ƀⓤffalo buƒfalɵ');
// -> 'Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo'
shoetest.complexify('This is Mars!');
// -> 'Thíṣ ịṥ Mârs!'
var options = {
charCase: true,
begin: '\\b',
end: '\\b'
}
shoetest.test('creme de la creme', c, options);
// -> false
shoetest.test('Creme de la Creme', c, options);
// -> true
shoetest.test('Alg', b);
// -> true
shoetest.test('Alg', b, options);
// -> false
Type: Boolean
Default value: true
Match strictly diacritics. In non strict mode, other special characters can be matched such as s
with $
or e
with €
.
Type: Boolean
Default value: false
Match the diacritics of the query.
Type: Boolean
Default value: false
Match the case of the query.
Type: Boolean
Default value: false
Match the symbols of the query.
Type: Boolean
Default value: false
Match the exact whitespaces of the query. For instance, by default, will allow a tabulation instead of a space.
Type: Boolean
Default value: true
Match the word boundaries of the query.
Type: String
Default value: ``
Add custom regular expression at the beginning of the query. Escape when necessary, e.g. \\b
instead of \b
.
Type: String
Default value: ``
Add custom regular expression at the end of the query. Escape when necessary, e.g. \\b
instead of \b
.
npm test
Pull requests are welcome. If you add functionality, then please add unit tests to cover it.
If you wish to update the reference list, only add special characters translated to 3 or less basic latin characters.