Regex search and replace

Hope someone can help... I am trying to replace some parts of my current code with regex in PHPStorm.  Cant quite seem to get my head around it..  I am trying to change $_POST['value'] to $this->input->post('value').

Is there a way I can do this with regex in PHPStorm to save time rather than have to go through every single line of code to change it.

Thanks

5 comments

Sure you can.

Search for:
\$_POST\['([^']+)'\]

Replace with:
\\$this->input->post('$1')

(Don’t forget to check the “Regex” checkbox)

Carsten

0

Posted at almost the same exact time!

0

Yeah. I had tried \$ and $$ before and looked it up in the documentation only afterwards.

Carsten

Edit: Sorry, I didn’t read your post correctly. In a previous version of my post, I had used a workaround for inserting the dollar character in the replacement string, because as a new PhpStorm user I wasn’t aware of having to double-escape the $.

0

Thanks a lot guys, the suggestions worked like a charm :)
Should help speed up my work...

0

Please sign in to leave a comment.