Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Created·2017-06-27 06:02
Flavor·JavaScript

/
^\[ *(((['"][-\w. ]+['"]|[-\w.]+), *)*)(['"][-\w. ]+['"]|[-\w.]+) *]$
/
Open regex in editor

Description

Matches strings that are formatted as arrays.

The following will match:

  • [ 3.4, -600, foo ]
  • ["foo","bar"]
  • [ bar, 1600 ]
  • [ foo ]
  • `[ "foo bar" ]

But these won’t match:

  • 3.4, -600, foo
  • [ "foo" "bar" ]
  • [ foo bar ]
Submitted by Chris Swithinbank