Extracting final word in sentence through regular expression

regex

I can't find a way to extract the final word on a line, such as this:

^This is a sentence$

I'd like to extract just "sentence". Does someone have an idea?

Thank you.

Best Answer

If the final word is preceded by a space, all you need is:

\s(\w+)$

The last word in the sentence will then be captured.

Related Question