How do I modify Input search with regular expression to filter on first word of a column only?
How do I modify Input search with regular expression to filter on first word of a column only?

I have this in my code and it doesn't seem to work.
$('input[type = search]').on( 'keyup', function () {
dataTableExample.column(0).search("\ba"+ this.value, true, false, true).draw();
alert('hello');
});
So if I enter ma in the input field, it filters to AMA, management, magma, etc. What I would really want is it to filter to management and column values that start with MA and not contain MA.
I am sure I'm doing something stupid, so feel free to point it out to me.
This question has an accepted answers - jump to answer
Answers
Hi @BPAT ,
If you use regular expressions (there'll be loads of links on Google), it'll be easy - something like
"^MA"
,Cheers,
Colin
You need to escape the backslash like this: `"\b". For example:
http://live.datatables.net/sinaxapa/1/edit
Took me a minute to realize that problem
Kevin