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

3.62K viewsProgramming

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

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

Answered question
You are viewing 1 out of 1 answers, click here to view all answers.
Write your answer.