Weird Regex Behavior
Weird Regex Behavior
I'm using this example because I want a pre-filtering to occur when my table loads:
https://datatables.net/reference/option/searchCols
But I have no idea what is going on with the regex behavior. I'm trying to use the OR operator in my expression. Is this true regex?
This Works:
"Analyst Progress"
This Doesn't Work:
"Analyst Progress|Review"
But this does work...:
"Analyst Progress|*" (with asterisk)
Snippet:
"searchCols": [
{ "search": "Analyst Progress|Review Progress", "regex": true},
null,
null,
null,
null
]
Using the asterisk seems to suggest the regex is working... I've also had success with a negative lookahead (^((?!Failed).)*$).
Furthermore I know my expression is good because I'm doing this same expression in column.search().draw(), this same expression works fine:
.search("(^((?!" + associatedTasks + ").)*$)", true, false)
.draw();
Any idea why this isn't working?
Hope this question makes sense.
This question has an accepted answers - jump to answer
Answers
Anyone can answer this if you want. Instead of doing that for pre-filtering, I did this instead:
$(window).on('load', function() {
v = this.value
table.columns(0)
.search("Analyst Progress|Review", true, false)
.draw();
});
I took your example an put into this test case:
http://live.datatables.net/feminipo/1/edit
Added the option
search.smart
and set tofalse
.This seems to work. Same as your search API with regex true and smart false.
Kevin
Awesome! I was not aware I needed to explicitly set smart to false. I expected by setting regex to true it would implicitly set smart to false. Thanks for the help.