Write JavaScript function that matches all words in a text, a word is anything that consists of letters, numbers or underscores (_).
The input comes as single string argument – the text from which to extract the words.
Examples:
Input:
'A Regular Expression needs to have the global flag in order to match all occurrences in the text'
Output:
A|Regular|Expression|needs|to|have|the|global|flag|in|order|to|match|all|occurrences|in|the|text
Input:
'_(Underscores) are also word characters'
Output:
_|Underscores|are|also|word|characters
The output should be printed on the console and should consist of all words concatenated with a “|“(pipe), check the examples bellow to better understand the format.