Regex in column search not working
Regex in column search not working
MarkvdB
Posts: 7Questions: 1Answers: 0
Hi!
I try the following Regex to filter multiple values in a single column:
$datatable.columns( 3 ).search('Samsung S9|Samsung S8',true, false).draw();
In the example https://datatables.net/examples/api/regex.html I get the pipe operator working, why not in my example?
When I remove "|Samsung S8" the columns get nicely filtered on "Samsung S9".
This discussion has been closed.
Answers
Hi MarkvdB,
Yep, that's right, take a look at this live example!
What happens for you when you specify both phones? Are you getting no search hits? Or just 'Samsung S8'?
Cheers,
Colin
'Samsung S9 Samsung S8' = no hits
'Samsung S9' = 10 hits // correct
'Samsung S8' = 3 hits // correct
'Samsung S9 Samsung S8' = (smart search) no hits
'Samsung S9|Samsung S8' = (smart search) no hits
Could you create a live example, like my one? As my example shows, the hits are right, so there must be something odd going on with your code.
hmm strange. Can it be a issue that I get the results via ajax serverside?
Edit:
I do think so:
Some work in progress, any tips?
Yep, it must be something to do with how your server-side script is handling that search request. My PHP isn't strong enough yet to be able to help with that I'm afraid, but hopefully somebody else could take a look.
C
Does anyone have a complete PHP serverside script capable of doing multiselects?
Current working concept:
Add:
$multiSearch = array();
Replace function with:
Add:
New fully working code: