mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-18 16:54:14 +01:00
Merge pull request #117 from timtucker/patch-29
Dev: Modify how DataTables builds the filtering regular expressions to simplify.
This commit is contained in:
commit
f420f1462b
@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
/**
|
||||
* Generate the node required for filtering text
|
||||
* @returns {node} Filter control element
|
||||
@ -336,22 +335,19 @@ function _fnBuildSearchRow( oSettings, aData )
|
||||
*/
|
||||
function _fnFilterCreateSearch( sSearch, bRegex, bSmart, bCaseInsensitive )
|
||||
{
|
||||
var asSearch, sRegExpString;
|
||||
var asSearch,
|
||||
sRegExpString = bRegex ? sSearch : _fnEscapeRegex( sSearch );
|
||||
|
||||
if ( bSmart )
|
||||
{
|
||||
/* Generate the regular expression to use. Something along the lines of:
|
||||
* ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$
|
||||
*/
|
||||
asSearch = bRegex ? sSearch.split( ' ' ) : _fnEscapeRegex( sSearch ).split( ' ' );
|
||||
asSearch = sRegExpString.split( ' ' );
|
||||
sRegExpString = '^(?=.*?'+asSearch.join( ')(?=.*?' )+').*$';
|
||||
return new RegExp( sRegExpString, bCaseInsensitive ? "i" : "" );
|
||||
}
|
||||
else
|
||||
{
|
||||
sSearch = bRegex ? sSearch : _fnEscapeRegex( sSearch );
|
||||
return new RegExp( sSearch, bCaseInsensitive ? "i" : "" );
|
||||
}
|
||||
|
||||
return new RegExp( sRegExpString, bCaseInsensitive ? "i" : "" );
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user