While matching for specific text in regex I want to traverse word by word rather than camparing whole string at once.
I am currently using this piece of code:
function processData(input) {
const regex= /our$||or$||our,$||our.$||or,$||or.$/;
var a=0;
if(regex.test(input))
a=a+1;
console.log(a);
}
I want to break the string input
into words and iterate over it (words by word).
I checked split()
function but no could not understand.