I want to get the next word after the matching phrase.
wait. - I want to change my pain threshold
--"Change my ***"
let text = "I want to change my pain threshold" let firstTriggerregEx = "(?:\b|')(change my)(?:\b|')"; const found2 = text.match(firstTriggerregEx); console.log(found2);
This will return the match, but not the following word
You can use the following modes:
(?
The first part is a positive review. It ensures that the following characters/groups are preceded by the specified pattern.
The second part consists of the "word character" (
[a-zA-Z0-9_]
) character set in the capturing group so that you can retrieve it later.https://regex101.com/r/CdKcVh/1