arrays - sed replace $_REQUEST["hello"] with functionName('hello') -
in old php app im still requesting parameters $_request, have function checks before returning.
so want variables $_request["hello"] replace function have _request('hello')
i tried following sed command, doesnt find $_request variables.
sed 's/$_request\["(.*)"\]/_request('\1')/g'
i tried different things escaping $ char or changing regex (.*), not work. wrong on one?
i use command save time changing $_request vars function call.
try this:
$ cat file sed replace $_request["hello"] functionname('hello') $ sed 's/\$_request\["\([^"]*\)"\]/_request('\''\1'\'')/g' file sed replace _request('hello') functionname('hello')
you need use '\'' because ' breaks shell need provide literal ' in shell followed ' sed. changed .* [^"]* it'll stop @ end of string rather last " on line.
Comments
Post a Comment