Artificial intelligent assistant

Swapping words with sed I need help with `sed`, actually with Linux regular expressions: I need to change two parameters between parentheses, for instance, if the line is mysqli_select_db($par1, $par2)<br/> I need to change it to mysqli_select_db($par2, $par1)<br/> I need something generic, they aren't always going to be `par1` and `par2`.

A more pedantic approach with `sed`:


sed 's/\(mysqli_select_db(\)\([^,]*\)\(,[[:space:]]*\)\([^)]*\))/\1\4\3\2)/g' file


* `s/` substitute
* `\(` start capturing group 1
* `mysqli_select_db(` match literal string
* `\)` end capturing group 1
* `\(` start capturing group 2
* `[^,]*` match any non-comma characters
* `\)` end capturing group 2
* `\(` start capturing group 3
* `,[[:space:]]*` match comma and optional space characters
* `\)` end capturing group 3
* `\(` start capturing group 4
* `[^)]*` match any non-`)` characters
* `\)` end capturing group 4
* `)` closing `)` of command
* `/\1\4\3\2)/g` replace with capturing groups 1, 4, 3, 2 and closing `)`

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 92750978f9713c3cd3507dae0418f449