3

Say I have text like that:

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

and I want to convert all letters to lowercase, but only if the line contains the word "models".

Resulting in this:

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

I know I can do this: (\w) -> \L$1 but it replaces every character.

I tried doing it like that:

models (\w) -> models \L$1 but any attempts like that are failing.

Destroy666
  • 12,350

1 Answers1

2

You can use:

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

Explantation:

  • ^ - match start of the line
  • .*? - anything, non-greedy, after and before the word you're looking for
  • [Mm]odels - case insensitive models. Wrap it in \bs to ensure that e.g. someothermodels isn't matched.
  • $ - end of line

Then replace with:

\L$0

which in Boost regex engine used by Notepad++/Sublime Text 3 means that \L will lowercase anything after it and $0 is full match, so entire matching lines.

Destroy666
  • 12,350