Regular Expressions 101

Community Patterns

Match string between brackets with two groups

0

Regular Expression
PCRE (PHP <7.3)

/
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 - 4 years ago