Search Using a RegExp Object
Search Using a RegExp Object

I'm using the following code to search for blank cells in a specific column:
column.search('^$', {
regex: true,
exact: false,
smart: false
}).draw();
It works, but this documentation states that;
Note that as of DataTables 2.0 this option is discouraged - if you wish to perform a regular expression search, pass the search term in as a
RegExp
object (rather than a string with a regex in it).
I've found forum posts where the RegExp
object is used, but I'm struggling to understand how to convert my code to use said object as there doesn't appear to be any documentation on using it - apologies if I've somehow missed it!
I'd be grateful if someone could point me in the right direction.
Many thanks.
This question has an accepted answers - jump to answer
Answers
columns.search(/^$/).draw()
should do it.Allan
@allan
Perfect. Thank you.
I should probably mention that doesn't work for server-side processing. Very much a client-side search action that. (Just in case anyone else finds this thread
).
Allan