Notepad++ regular expression find and replace $_REQUEST with $_GET but a more secure
- by David
What I am doing is replacing, in a large program, all $_REQUEST['var'] and mysql_escape_string($_REQUEST['var']) with either the 1st or 2nd line below the dotted line.
Now, I have figured out this much of the regular expression but I would like to make it simpler. Instead of having to run the top one first then the 2nd one I would like to just run one all together. I tried this but it did not work.
(mysql_escape_string\()*$_REQUEST\[\'([^']*)\'\]\)(\)*)
So below is what works but again have to do it twice.
$_REQUEST\[\'([^']*)\'\]
mysql_escape_string\($_REQUEST\[\'([^']*)\'\]\)
(isset($_GET['\1'])?mysql_real_escape_string($_GET['\1']):false)
(isset($_POST['\1'])?mysql_real_escape_string($_POST['\1']):false)
============================
Update: Yeah, after some research I figured out that Notepad++ does not support most regular expressions. I guess one additional step can not hurt a person. It's just laziness.
*NOTE: BUT if anyone wants to try feel free to comment.
At least it is just 2 steps and not 20.