I has a string like this:
const string = 'John Smith: I want to buy 100 apples\r\nI want to buy 200 oranges\r\n, and add 300 apples';
and now I want to split the string by following keywords:
const keywords = ['John smith', '100', 'apples', '200', 'oranges', '300'];
now I want to get result like this:
const result = [
{isKeyword: true, text: 'John Smith'},
{isKeyword: false, text: 'I want to buy '},
{isKeyword: true, text: '100'},
{isKeyword: true, text:'apples'},
{isKeyword: false, text:'\r\nI want to buy'},
{isKeyword: true, text:'200'},
{isKeyword: true, text:'oranges'},
{isKeyword: false, text:'\r\n, and add'},
{isKeyword: true, text:'300'},
{isKeyword: true, text:'apples'}];
Keywords could be lowercase or uppercase, I want to keep the string in array just the same as string.
I also want to keep the array order as the same as the string but identify the string piece in array whether it is a keyword.
How could I get it?