Regex to extract all but first and last word from a multi-word string

3.91K viewsProgramming
0

How can I write a regex that will return all but first and last words from a multi-word string ?

For eg:- “William Henry Gates” should return “Henry”

Changed status to publish
0

Here it is:-
 /\s+\w+(?: \w+)*\s+/g

Answered question
Write your answer.

Categories