j4s0n
j4s0n

Reputation: 13

regex string replace using Sublime 3

I'm using Sublime 3 for a string replace task inside a lengthy PHP file. I would like to achieve the following.

Turn all instances of this pattern (there are about 100):

$data['xyz']

Into this:

Mything()->settings->get('xyz')

Throughout the PHP file, the pattern is identical to above except the 'xyz' part differs from instance to instance and should be preserved by the regex.

Upvotes: 0

Views: 2440

Answers (1)

degant
degant

Reputation: 4981

Using regular expressions

Find:

\$data\['(.*?)'\]

Replace:

Mything()->settings->get('\1')

Regex101 Demo

Don't forget to enable Regular Expressions while using find and replace in SublimeText

Upvotes: 3

Related Questions