Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(__|_e)\(\s?(('|")(((?!(?<!\\)\3).)*)\3)(\s?|\s?(,\s?(''|""))?)\)
/
gm

Description

In a WordPress project, when you miss the text domain in i18n functions, the strings will not be translated. With this regex you can check if the i18n functions __() and _e() have their text domain, and eventually use the substitution provided for adding it.

Submitted by anonymous - 5 years ago