0
1

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.

【サクラエディタ】全角数字⇒半角数字変換するマクロ

Posted at
zenkakuNumToHankaku.js
var convData = {
  "":0,
  "":1,
  "":2,
  "":3,
  "":4,
  "":5,
  "":6,
  "":7,
  "":8,
  "":9
};

var str = Editor.GetSelectedString(0);
var result = str.replace(/([0-9])/g,
  function ($0){
    return $0.replace(/[0-9]/g , function($0){return convData[$0];});
  });
Editor.InsText(result);

使用例

対象行を選択して、当マクロを実行する。

実行前

TEST111TEST222TEST333
TEST111TEST222TEST333
TEST111TEST222TEST333

実行後

TEST111TEST222TEST333
TEST111TEST222TEST333
TEST111TEST222TEST333
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?