I want do all the operation of sql 'like' in javascript. for example:
var str="South-Asia, North-America, South-Africa";
var firstwordmatch=South%; //will result South-Asia,South-Africa
var last match=%ica // will match North-America, South-Africa
What I have tried is the following:
var ex = str.split('%')[1]; // this for matching %ica
var l = str.length;
var n = str.indexOf("%");
// this for matching %ica
if (n == 0) {
var m = c.match(/(.*)ex/)
}
// this for matching
// this for matching south%
else if (n == l - 1) {
var m = c.match(/ex(.*)/)
}
but I am unable to write the correct regular expression because it does not get the ex variable.