Searching using regex for number of dates
Searching using regex for number of dates
iamstevevan
Posts: 8Questions: 4Answers: 0
I am trying to search through my datatable to find out how many rows are time stamped as a certain month. I am doing this by:
var table = $('#example').DataTable();
var monthRegex = '';
var monthResults
for (i = 1; i <= 12; i++) {
monthRegex = '^(['+i+']\/[1-9]{1,2}\/2014)$'
monthResults = table.column(2).search( monthRegex, true, true );
}
Regex works, as tested at regex101.com.
What am I missing?
This discussion has been closed.
Answers
I also should mention I do not want to redraw.
Figured this out. I am only applying the search. I needed to add
var monthRegex = '';
var monthResults
for (i = 1; i <= 12; i++) {
monthRegex = '^(['+i+']\/[1-9]{1,2}\/2014)$'
monthResults = table.column(2).search( monthRegex, true, true );
monthResults = table
.columns( [2], { search: 'applied', order:'current', page:'all' } )
.data();
}