Regular Expressions 101

Community Patterns

Translatable string matcher for Laravel

0

Regular Expression
PCRE (PHP <7.3)

/
[^\w](?<!->)(trans|trans_choice|Lang::get|Lang::choice|Lang::trans|Lang::transChoice|@lang|@choice|__)\s*\(\s*((?<![\\])['"])((?:.(?!(?<![\\])\2))*.?)\2\s*[,\)]
/
g

Description

When searching translatable strings in Laravel, this Regex will match all quoted string labels and JSON message localizations.

Submitted by anonymous - 4 years ago