
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
화면 캡처: