Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var input = [
- ['in', 'We are living in a yellow submarine. We don\'t have anything else. Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days.'],
- ['your', 'No one heard a single word you said. They should have seen it in your eyes. What was going around your head.'],
- ['but', 'But you were living in another world tryin\' to get your message through.']
- ];
- function countSubstringOccur(value) {
- var delim = value[0];
- var text = value[1];
- var regex = new RegExp(delim, 'gi');
- //console.log(text.match(regex));
- var occurencesCount = (text.match(regex) || []).length;
- console.log(occurencesCount);
- }
- input.forEach(countSubstringOccur);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement