Notepad++ アンダースコアで始まる大文字の単語をすべて検索し、適切な大文字に変換します

Notepad++ アンダースコアで始まる大文字の単語をすべて検索し、適切な大文字に変換します

Notepad++ を使用して、アンダースコアで始まる大文字のすべての単語を検索し、適切な大文字/小文字に変換したいと考えています。

例1、

Find:
DimCalendarDay_DATE

Replace with:
DimCalendarDay_Date

例2、

Find:
DimCalendarDay_YEAR_PERIOD_DAY

Replace with:
DimCalendarDay_Year_Period_Day

例3、

Find:
First_Day

Replace with:
First_Day

Notepad++ の検索広告置換基準にはすでに次の内容を入力しています。

Find what:  [_]\w*[A-Z]\w*[A-Z]\w* 
Replace with:  \L \u \1

ただし、上記の正規表現では、見つかったテキストが何も置き換えられません。

お知らせ下さい...

答え1

  • Ctrl+H
  • 検索対象:(_[A-Z])([A-Z]*)(?![A-Z])
  • と置換する:\u$1\L$2
  • チェック大文字と小文字を一致させる
  • チェック ラップアラウンド
  • 正規表現をチェック
  • Replace all

説明:

(_[A-Z])    # group 1, an underscore followed by a capital
([A-Z]*)    # group 2, 0 or more capitals
(?![A-Z])   # negative lookahead, make sure we haven't capital after

交換:

\u$1        # uppercased the content of group 1 (i.e. the first letter)
\L$2        # lowercased the content of group 2 (i.e. the rest of the match)

与えられた条件:

DimCalendarDay_DATE
DimCalendarDay_YEAR_PERIOD_DAY
First_Day

与えられた例の結果:

DimCalendarDay_Date
DimCalendarDay_Year_Period_Day
First_Day

画面キャプチャ:

ここに画像の説明を入力してください

関連情報