Results 1 to 4 of 4
I was wondering if it was possible to use SED to replace a string of the form:
$_POST['variable'] with getVar('variable') ? I have tried a few expressions with no success. ...
- 11-12-2008 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 2
A Basic SED question.
I was wondering if it was possible to use SED to replace a string of the form:
$_POST['variable'] with getVar('variable') ? I have tried a few expressions with no success. Any help would be greatly appreciated.
- 11-15-2008 #2Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
how about
echo -e "\$_POST['variable']" | sed -e "s#\$_POST\['variable'\]#getVar('variable')#g"
- 11-16-2008 #3Just Joined!
- Join Date
- Nov 2008
- Posts
- 2
I actually replaced most of the instances of this manually. But I am still interested in the solution to this problem. I was unclear in the previous post. What i was looking for is $_POST['variable'] replaced with getVar('variable') , where 'variable' is itself non-constant through out the file. I am just using 'variable' as a place-holder for any term there. I was able to replace $_POST[ with getVar( but how does one match and replace that last bracket with a parenthesis?
- 11-16-2008 #4Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
Replace the sed part with
sed -e "s#\$_POST\[\(.*\)]#getVar(\1)#g"


Reply With Quote