Regular Expressions 101

Community Patterns

t() argument extractor

1

Regular Expression
PCRE (PHP <7.3)

/
t\s*\(('|"|<<<(\w+))([\s\S]+?)(?:(?<!\\)\1|\2)
/

Description

Extracts the string passed to the Drupal t() function and keeps the string in the 3rd capture.

Submitted by Travis Uribe - 8 years ago