0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

vscode 関数 正規表現 置換

Posted at

vscode 関数 正規表現 置換

自分がCIの改善(主にソースコード周り)やる時に見る用。
vscodeの左の方でてくるテキストボックスのsearchとreplaceに入れること。

method名

method(arg1) → new_method(arg1)

search

method

replace

new_method

引数

method(var1) → method(1)
method(var2) → method(1)
method(var3) → method(1)

search

method\((.*)\)

replace

method(1) 

methodの中にmethod

assert_equal 1, method(value, method2(100)) → assert_equal 1, method(value, method3(100)) 

assert_equal 1, method(value, method2(200)) → assert_equal 1, method(value, method3(200)) 

search

method2\((.*)\)

replace

method3($1)

引数の順番入れ替え

method(var1, var2) → method(var2, var1)
method(a, b) → method(b, a)
method(99, 2) → method(2, 99)

search

method\((.*), (.*)\)

replace

method($2, $1)

括弧なし

assert_equal 1, var1 → assert_equal 1, var3
assert_equal 1, var2 → assert_equal 1, var3

search

assert_equal (.*), (.*)

replace

assert_equal $1, var3
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?