Regex search with multiple values
Regex search with multiple values
I'm working on implementing a feature into the datatable we are currently using to search multiple account numbers at once. The column I'm trying to search has probably 50-60 numbers, and I want to be able to search a few at a time. With that being said, I've produced the following code:
this.column(val).search("^(" + searchSource.replace(',', '|') + ")$", true, false, true).draw();
and users can use the following to search for multiple values: "40,22".
When I go further than 2 values, for instance "40,22,205" it will only show the first value, "40"
tl:dr - I can search for 2 values but not more than 2. Anything past 2 values causes only the first value to be searched.
Replies
I think you will to place each number in a set of parenthesis, like this:
http://live.datatables.net/nacagiji/1/edit
Kevin
Hey Kevin,
Thanks! That works almost perfectly, I have numbers like "40,17,400017" etc. When I put in 40, 400017 also shows up. Is there a way to make it only show 40? Here's an example using the link you provided:
http://live.datatables.net/wojinewe/1/edit
Use
\b
for word boundary around each number, like this:http://live.datatables.net/wugafado/1/edit
Kevin
You've solved it. Thanks!