I have a text as below and some words and their meanings are included in the text.I need to get these words using a Javascript regex method. For example, if I give below text than return words should be Necessity, Lay of the land, and Mumble.
Necessity:(noun)the need for something, or something that is needed Example: In my work, a computer is a necessity.
Lay of the land: (idiom n. Or v.)the general state or condition of affairs under consideration; the facts of a situation Example: We asked a few questions to get the lay of the land
Mumble:(verb) to speak quietly or in an unclear way so that the words are difficult to understand Example: She mumbled something about needing to be home, then left.
I have coded as below but it doesn't work as expected.
let text = `Necessity:(noun)the need for something, or something that is needed
Example: In my work, a computer is a necessity.
Lay of the land: (idiom n. Or v.)the general state or condition of affairs under consideration; the facts of a situation
Example: We asked a few questions to get the lay of the land.
Mumble:(verb) to speak quietly or in an unclear way so that the words are difficult to understand
Example: She mumbled something about needing to be home, then left.
`;
let matches = text.match(/[A-Za-z]+(?=\:\S)/g);
console.log(matches); //['Necessity', 'Mumble']
May I know what am I missing? Any help would be appreciated.
