Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
((?:[\w'-]+,\s+)+(?:[\w'-]+\s){0,2}[\w'-]+)(\s+(and|or)\s+[\w'-]+)
/
gi

Description

Insert comma in lists before the word "and" or "or".

Submitted by Mogsdad w/ assist from TerryAtOpus - 9 years ago