Regular Expressions 101

Community Patterns

regex to get N words from a line

1

Regular Expression
ECMAScript (JavaScript)

/
^((?:\w+\s?){1,12}).*
/
gm

Description

usefull if you want to return (N) words instead of (N) chars

Submitted by Pavel Dominguez - 9 years ago