Reputation: 11
I want to construct a regular expression in Javascript with 'OR' condition for me to input that into a fnFilter()
function call to do column multi filtering.
Let's say I want to filter a column for values either A or B.
var string1 = 'A';
var string2 = 'B';
If I use '|' between these two strings, it's treated as bit wise OR operator.
oTable.fnFilter(string1 | string 2, columnIndex, true, false);
If I use '||' between these two strings, it's treated as logical OR operator.
oTable.fnFilter(string1 || string 2, columnIndex, true, false);
What I should insert or do more to make it work like a regular expression, which brings the meaning, either A or B, and filter the column for values either A or B?
Upvotes: 0
Views: 114
Reputation: 117
You could instance the RegExp
object like so:
var filterRegEx = new RegExp(string1 + '|' + string2, 'g');
oTable.fnFilter(filterRegEx, columnIndex, true, false);
Upvotes: 0