Notepad++/Sublime Text 3에서 정규식으로 모든 텍스트를 소문자로 만드는 방법은 무엇입니까? 단, 줄에 특정 문구가 있는 경우에만 가능합니까?

Notepad++/Sublime Text 3에서 정규식으로 모든 텍스트를 소문자로 만드는 방법은 무엇입니까? 단, 줄에 특정 문구가 있는 경우에만 가능합니까?

다음과 같은 텍스트가 있다고 가정해 보겠습니다.

models/players/clonespac/CloneTorsoLieutenant
{
    q3map_nolightmap
    q3map_onlyvertexlighting
    {
        map models/players/clonespac/CloneTorsoLieutenant
        blendFunc GL_ONE GL_ZERO
        rgbGen lightingDiffuse
    }
    {
        map gfx/effects/clone
        blendFunc GL_DST_COLOR GL_SRC_COLOR
        tcGen environment
        blendFunc GL_SRC_ALPHA GL_ONE
        detail
        alphaGen lightingSpecular
    }
}

그리고 난 하고 싶어모든 문자를 소문자로 변환합니다. 단, 줄에 해당 단어가 포함된 경우에만 해당됩니다."모델".

결과는 다음과 같습니다.

models/players/clonespac/clonetorsolieutenant
{
    q3map_nolightmap
    q3map_onlyvertexlighting
    {
        map models/players/clonespac/clonetorsolieutenant
        blendFunc GL_ONE GL_ZERO
        rgbGen lightingDiffuse
    }
    {
        map gfx/effects/clone
        blendFunc GL_DST_COLOR GL_SRC_COLOR
        tcGen environment
        blendFunc GL_SRC_ALPHA GL_ONE
        detail
        alphaGen lightingSpecular
    }
}

나는 이것을 할 수 있다는 것을 알고 있습니다: (\w)-> \L$1그러나 그것은 모든 문자를 대체합니다.

나는 다음과 같이 해보았습니다.

models (\w)-> models \L$1하지만 그런 시도는 모두 실패합니다.

답변1

당신이 사용할 수있는:

^.*?[Mm]odels.*?$

적출:

  • ^- 라인의 시작과 일치
  • .*?- 원하는 단어 앞뒤 모두, 탐욕적이지 않은 것
  • [Mm]odels- 대소문자를 구분하지 않습니다 models. \b예를 들어 일치하지 않는지 확인하려면 s 로 감싸십시오 someothermodels.
  • $- 줄 끝

그런 다음 다음으로 바꾸십시오.

\L$0

Notepad++/Sublime Text 3에서 사용하는 Boost 정규식 엔진에서는 \L그 뒤의 모든 항목을 소문자로 만들고 $0전체 일치하므로 전체 일치 라인을 의미합니다.

관련 정보