2
$_POST['daily_limit'];
$whatever = $_POST['smoke'];
$_POST['soup'] + $_POST['cake'];

$this->input->post('daily_limit');
$whatever = $this->input->post('smoke');
$this->input->post('soup') + $this->input->post('cake');

この例では、正規表現の検索と置換を記述せずにから$_POST[]に切り替えるためのより高速な方法はありますか?$this->input->post()それが複数のステップを踏むかどうかは気にしません。このための正規表現の作成(検索:\$_POST\[(.*?)\]置換:)は\$this->input->post\($1\)、すべてを手動で変更するよりも時間がかかります(おそらく、正規表現が苦手なだけです)。何か案は?

4

2 に答える 2

1

ここでは、角かっこの各ペア内に変数が1つしかないこと、および変数に英数字のみが含まれていることを大雑把に想定しています。['soup'+'bacon']と同様に、このトリックを破ります['soup-with-bacon']

カーソルで、$_POST[-他には何もないインスタンスを強調表示します。

Windows / Linuxを使用している場合はAlt+を押します( Macでは+ ?)F3CmdShiftG

スクロールして、選択したものがすべて置き換えたいものであるかどうかを確認してください。

タイプ$this->input->post(-他には何もありません。

プレス→</kbd> to move all cursors to the right of the first quote.

Ctrl+を押します→</kbd> (this is the only remotely wtfh4xxy part of the process, and only if you're not used to navigating by word with the cursor) to navigate over the variable.

プレス→</kbd> twice to move all cursors to the right of the next quote.

をに置き換え]ます)

于 2012-11-16T20:07:40.310 に答える
1

@nnnn wtfh4xxyの部分を削除するために、バージョンのバリエーションを作成しました。

選択する:$_POST

altf3

タイプ:$this->input->post(

ctrlshiftm

ctrlx

ctrlshiftm

ctrlv

タイプ:)

崇高なテキストftw!

于 2012-11-16T22:03:19.650 に答える