Regular Expressions 101

Community Patterns

identify and extract Laravel-style route parameters

1

Regular Expression
PCRE2 (PHP >=7.3)

/
{([^:{}]+)(:([^{}]+))?}
/
gm

Description

Extracts a table/model name, and optionally a column name. Enforces well-formed parameters. Tested with /category/{aYes:bYes}/{cYes}/{dNo:}/{eNo:/{:fNo}

Submitted by Martin Holt - 10 months ago