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 1 year has passed since last update.

正規表現で〜年以降を置換する

Last updated at Posted at 2019-11-28

2020年以降、「体育の日」が「スポーツの日」へ変更になります。

・国民の休日について −内閣府
https://www8.cao.go.jp/chosei/shukujitsu/gaiyou.html

そんなとき、祝日のマスターをファイルで定義しているときに
2020年以降は置換する必要があったので正規表現でできるなと試したので、
備忘的に記録しておこうと思います。

例えばこんなファイル

2015-01-01  元日
2015-01-12	成人の日
2015-02-11	建国記念の日
2015-03-21	春分の日
2015-04-29	昭和の日
2015-05-03	憲法記念日
2015-05-04	みどりの日
2015-05-05	こどもの日
2015-05-06	休日
2015-07-20	海の日
2015-09-21	敬老の日
2015-09-22	休日
2015-09-23	秋分の日
2015-10-12	体育の日
2015-11-03	文化の日
2015-11-23	勤労感謝の日
2015-12-23	天皇誕生日
・・・
・・・
・・・
2020-01-01	元日
2020-01-13	成人の日
2020-02-11	建国記念の日
2020-02-23	天皇誕生日
2020-02-24	休日
2020-03-20	春分の日
2020-04-29	昭和の日
2020-05-93	憲法記念日
2020-05-04	みどりの日
2020-05-05	こどもの日
2020-05-06	休日
2020-07-23	海の日
2020-07-24	体育の日
2020-08-10	山の日
2020-09-21	敬老の日
2020-09-22	秋分の日
2020-11-03	文化の日
2020-11-23	勤労感謝の日
・・・
・・・
・・・

操作

VSCode(visual studio code)
ctrl + shift + h
で置換を呼び出せますね。
(正規表現のチェックを忘れないこと)

検索欄:
(.*20[2-9][0-9].*)体育の日

置換欄:
$1スポーツの日

これで2020年〜2099年まで簡単にできます。

以上です。

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?