Вопрос

How can i replace

$lang['abc'] with lang('abc')

and

{$lang['abc']} with ".lang('abc')."

including quotes.

Where i am stuck is how RegExp can save 'abc' to be used in replaced text

Это было полезно?

Решение

First one (tested in N++):

Search: \$lang\['(abc)'\]

Replace: lang\('$1'\)

Second one (also tested in N++):

Search: \{\$lang\['(abc)'\]\}

Replace: ".lang\('$1'\)."

The back reference mentioned by devnull is the content of the (abc) parentheses. The parentheses capture abc into Group 1. That content is referred to in the replacement as "$1". You may like to read all about regex capture.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top