How to search for a range with different digit count
How to search for a range with different digit count
I'm applying a "search" filter to limit to a range of values.
This works:
table.column(9).search('[0-1][0-9]|2[0-5]', true, false).draw();
to find values from 10 - 25, but I also need it to include values from 0-9. I don't know what syntax to use to get the result in this jsfiddle:
http://jsfiddle.net/rvgraham/Up2f2/
In other words, I don't know the syntax to supply as a string that will "OR" one digit numbers or two digit numbers. I can only get it to "OR" different two digit combinations.
Did more research, this also works:
table.column(9).search('1\\d|2[0-5]', true, false).draw();
(to get 10-25)
So why doesn't this work:
table.column(9).search('\\d|1\\d|2[0-5]', true, false).draw();
to get 0-25???
In fact, how would you force it to match an exact regex? Using '0' matches any value with 0 anywhere, and it seems to ignore the ^ and $ begin/end switches.
OK, ANSWERED myself...
The column is rendered with a percent sign. Looking "under the covers" it appeared tto me that the regex was being compared to the data value (an integer), not the text value with the percent sign.
This does the job:
table.column(9).search('^\\d%$|1\\d|2[0-5]', true, false).draw();
Thanks in advance, Bob