How to get a boolean indicating if a search is using regex?
How to get a boolean indicating if a search is using regex?
julmot
Posts: 7Questions: 3Answers: 0
I know that the methods instance.search()
and instance.column(1).search()
are returning a search string. But, how can I know if they should be triggered like a regex? I mean, regex search can be activated by either using
$("something").DataTable({
"search": {
"regex": true
}
});
or by activating the regex flag in the .search()
method. But even then, the above named methods return a string.
This discussion has been closed.
Answers
I'm sorry to say that there is no public API for this at the moment. You could use the internal
settings()
object (oPreviousSearch.bRegex
), but that is currently the only way I'm afraid.If you do use that, I would suggest creating a plug-in API method so that you can easily update it in future should it change (it probably will for the next major version).
Allan
Thank you for your answer.
I'm afraid that
oPreviousSearch.bRegex
will probably not solve this problem. I need to determine if a global search and if searches for specific columns are made with the regex option. This property will probably only return a boolean for the latest search, but when doing multiple searches through different columns I'm not able to determine if they were done with that option.aoPreSearchCols
is the name of the array in the settings object for the column search information. Each object in there also has abRegex
parameter. This likely will also change in the next major version I'm afraid (although not sure when that will be yet).Allan