Regular Expressions 101

Community Patterns

Capturing elements inside square brackets

1

Regular Expression
PCRE2 (PHP >=7.3)

/
\[([^\,]+),\s*([^\,]+),\s*([^\,]+)\]
/
gm

Description

Using regex, you can use a pattern that takes three comma-separated elements and then extracts the third element from inside the brackets.

Submitted by anonymous - 8 months ago