regex – Regular expression to swap variable pair in mysql in PHP file


Which expression can I use to be able to change the parameters of the MYSQL function, example:



Because I look for mysql_query and change to mysqli_query after I manage to make this change.

That is, swapping two strings that are inside a parentheses.


You can invert the arguments by creating three groups at the end, just format the substitution.

The idea is to break this statement as follows, the first group is mysql_query the second $query and the third $db . With the captured elements, reverse the order of the second with the third and add the parentheses.

The first takes the statement: (mysql_query) the second the variable with the query ( \$\w+ ), which is represented by a dollar sign followed by one or more letters, followed by a comma and one more variable.

Search by:


Replace with:


Or yet:

Scroll to Top