Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^[\s;]+(?<![^\s;])|(?<=;)[\s;]*|(?<=[^\s;])\s*|(?![^\s;])[\s;]+$
/
gm

Description

cleans up a semicolon delimited list (remove white spaces, multiple semicolons, semicolons at the beginning or the end)

Submitted by anonymous - 6 years ago