Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RegExp for every word except first word of a sentence

I need a RegExp in JavaScript that matches everything except for the first word of each sentence. For example:

This is a super cool sentence.  Immediately following is this sentence.  Super cool story bro.

What I need is:

**** is a super cool sentence.  *********** following is this sentence.  ***** cool story bro.

I have this, which is the exact opposite of what I need (matches first word of each sentence):

(?:^|(?:[.!?]\s))(\w+)

Can anyone help me reverse this regexp so I get everything except the first word of each sentence?

like image 975
bcarroll Avatar asked Oct 22 '25 14:10

bcarroll


1 Answers

This regex will return an array of sentences without the first words from each:

/\s*\w*\s*([\w\s,;'\"]+[.?!])/gi
like image 115
John Avatar answered Oct 25 '25 04:10

John