Regular Expressions 101

Community Patterns

Match pointless spaces in space separated list

1

Regular Expression
ECMAScript (JavaScript)

/
^ +|( )(?=\1)| +$
/
g

Description

'test' - no match 'test test' - no match ' test' - match (space at the start) 'test ' - match (space at the end) 'test test' - match (single space in the middle)

Submitted by J. Harry B. - 8 years ago