1

Using Notepad++, I'm looking to find all words with ALL CAPS starting with underscore and to convert them to proper case.

Example 1,

Find:
DimCalendarDay_DATE

Replace with:
DimCalendarDay_Date

Example 2,

Find:
DimCalendarDay_YEAR_PERIOD_DAY

Replace with:
DimCalendarDay_Year_Period_Day

Example 3,

Find:
First_Day

Replace with:
First_Day

I already have entered the following within my Notepad++ search ad replace criteria:

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

However, the above regex replaces my found text with nothing.

Please advise...

1
  • Ctrl+H
  • Find what: (_[A-Z])([A-Z]*)(?![A-Z])
  • Replace with: \u$1\L$2
  • check Match case
  • check Wrap around
  • check Regular expression
  • Replace all

Explanation:

(_[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

Replacement:

\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)

Given:

DimCalendarDay_DATE
DimCalendarDay_YEAR_PERIOD_DAY
First_Day

Result for given example:

DimCalendarDay_Date
DimCalendarDay_Year_Period_Day
First_Day

Screen capture:

enter image description here

  • Excellent! Perfectly addresses my question! – user2525492 Jul 2 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.