Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(?<!^| ) (\w+?)(?:\r\n?|\n|\z)
/
g

Description

This expression grabs the last word in a line of text up to the first space it encounters reading from the back of the line (negative look behind)

Submitted by James Dafferner - 7 years ago