36
36

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 5 years have passed since last update.

正規表現で大文字や小文字に置換する

Last updated at Posted at 2014-06-19

\uや\lを使えば、大文字や小文字に置換することができます。

大文字へと置換

たとえば

foo_bar_hoge_piyo


(^|_)(.)\u\2に置換すると、

FooBarHogePiyo

とアッパーケースにできます。

小文字へと置換

LOG_FILE.TXT

(.)\l\1に置換すれば

log_file.txt

とロワーケースにできます。

使えないエディタもあります

エディタによっては、採用している正規表現エンジンの違いで大文字/小文字への置換ができません。
Vimや、Windowsだとサクラエディタなら使えます。

36
36
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
36
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?