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
请先登录再写评论。
Sure you can.
Search for:
\$_POST\['([^']+)'\]
Replace with:
\\$this->input->post('$1')
(Don’t forget to check the “Regex” checkbox)
Carsten
Find:
\$_POST\['(.*?)']
Replace:
\\$this->input->post('$1')
Posted at almost the same exact time!
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 $.
Thanks a lot guys, the suggestions worked like a charm :)
Should help speed up my work...