Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(^([\S]+)([ ])([\S]+)([ ])([\w\d]+)|^(.*)|^(.*)(.*))
/
gm

Description

This regex will find the first 3 words in every row, including any non-whitespace characters and also finds the words if the row has only 1 or 2 words

Submitted by ZoltanBiro - 7 years ago