Community Patterns

Community Library Entry

1

Regular Expression
Created·2015-12-01 21:02
Flavor·ECMAScript (JavaScript)

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

Description

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

Submitted by Mogsdad w/ assist from TerryAtOpus