user2910756
user2910756

Reputation: 23

Regex to replace one function with another in sed

I'm looking for a regex that I can call from a Linux command line that would replace a PHP function such as:

my_function($one,$two) 

with:

my_new_function($one)->command()

I tried:

s/my_function\(\$one,\$two\)/my_new_function\($one\)->command\(\)/g 

but that doesn't seem to match it. $two is no longer required.

Upvotes: 2

Views: 105

Answers (1)

Eraklon
Eraklon

Reputation: 4288

You don't have to escape parentheses. Try this 's/my_function(\$one,\$two)/my_new_function(\$one)->command()/g'.

Upvotes: 1

Related Questions