I would like to match the following term in JavaScript using regex.
String = 'abc AND def AND igk AND lmn'
Terms to match:
the word before and after first AND.
For example in the above string the match part will be : abc AND def.
I want to do it in JavaScript. So I will call
string.match(/regex to use/)
and assign it to a var.
Any suggestions please.
EDIT:
the string can be of form like:
string = 'AND abc';
string = 'abc AND';
string = 'abc def AND igk lmn';
string = 'abc def AND';
string = 'AND igk lmn';
Appreciate your help in this regard.
'AND'(and if so, what should happen)?abcif your string is'abc'(no AND at all)?