Regular Expressions 101

Match string between brackets with two groups

Open Workspace
  • PCRE (Legacy)
  • Match
0

Regular Expression

/
jform\[([\w\-]+)\]\[?([\w\-]+)?\]?
/
gm

Description

Matches all alphanumeric (\w), underscore and dash (-) that is included in square brackets ([]). The result gives two groups that can be used with $1 and $2.

Submitted by Anonymous