
次のようなテキストがあるとします:
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
- 大文字と小文字は区別されません。eg が一致しないように smodels
で囲みます。\b
someothermodels
$
- 行末
次に、次のように置き換えます。
\L$0
Notepad++/Sublime Text 3 で使用される Boost 正規表現エンジンでは、これは、\L
その後にあるものすべてを小文字にし、$0
完全一致、つまり一致する行全体を意味します。