0

So I posted a question earlier and got answered by user Dmytro Dzyubak, everything worked, but now I'm trying to make it work faster. More details below.

Before:

SkinMesh
{
    skin = "Art/Models/Effects/enviro_effects/misc/blood_orb/BloodOrb.sm"
}

SoundEvents
{
    soundbank = "_Effects_misc_blood_orbs.bank"
    animation = "enter"
        0 = "Audio/Sound Effects/Misc/BloodOrb/Start_$(#).ogg@2 120 0 0.1 0.1 0 -1 0 1 1"
    animation = "exit"
        0 = "Audio/Sound Effects/Misc/BloodOrb/End_$(#).ogg@1.6 115 0 0 0 0 -1 0 1 1"
    animation = "idle"
        0 = "Audio/Sound Effects/Misc/BloodOrb/Orb_$(#).loop.ogg@0.4 115 0 0 0 0 -1 0 10 4.5"
}

BoneGroups
{
    bone_group = "mid false mid jnt_orb_01 "
    bone_group = "cyl false mid cyl "
    bone_group = "explode false jnt_orb_01 up_explode "
    bone_group = "explodecyl false jnt_orb_01 cyl_explode1 "
    bone_group = "midparticle false mini_orb1 mini_orb_particleup_02 "
}

As you can see, there are a bunch of brackets. Is it possible to delete only text inside:

SkinMesh
{
    skin = "Art/Models/Effects/enviro_effects/misc/blood_orb/BloodOrb.sm"
}

and

SoundEvents
{
    soundbank = "_Effects_misc_blood_orbs.bank"
    animation = "enter"
        0 = "Audio/Sound Effects/Misc/BloodOrb/Start_$(#).ogg@2 120 0 0.1 0.1 0 -1 0 1 1"
    animation = "exit"
        0 = "Audio/Sound Effects/Misc/BloodOrb/End_$(#).ogg@1.6 115 0 0 0 0 -1 0 1 1"
    animation = "idle"
        0 = "Audio/Sound Effects/Misc/BloodOrb/Orb_$(#).loop.ogg@0.4 115 0 0 0 0 -1 0 10 4.5"
}

and leave BoneGroups untouched?

Here is an example of how it should look:

SkinMesh
{
}

SoundEvents
{
}

BoneGroups
{
    bone_group = "mid false mid jnt_orb_01 "
    bone_group = "cyl false mid cyl "
    bone_group = "explode false jnt_orb_01 up_explode "
    bone_group = "explodecyl false jnt_orb_01 cyl_explode1 "
    bone_group = "midparticle false mini_orb1 mini_orb_particleup_02 "
}

2 Answers2

2
  • Ctrl+H
  • Find what: \b(?:SkinMesh|SoundEvents)\s+\{\K.+?(?=\})
  • Replace with: \n
  • check Match case
  • check Wrap around
  • check Regular expression
  • CHECK . matches newline
  • Replace all

Explanation:

\b                  # word boundary
(?:                 # start non capture group
    SkinMesh        # literally "SkinMesh"
  |                 # OR
    SoundEvents     # literally "SoundEvents"
)                   # end group
\s+                 # 1 or more any spaces (including linebreak)
\{                  # openning curly bracket
\K                  # forget all we have seen until this position
.+?                 # 1 or more any characters including linebreak
(?=\})              # positive lookahead, make sure we have a closing curly bracket after.

Replacement:

\n      # linefeed, you may use \r\n

Result for given example:

SkinMesh
{
}

SoundEvents
{
}

BoneGroups
{
    bone_group = "mid false mid jnt_orb_01 "
    bone_group = "cyl false mid cyl "
    bone_group = "explode false jnt_orb_01 up_explode "
    bone_group = "explodecyl false jnt_orb_01 cyl_explode1 "
    bone_group = "midparticle false mini_orb1 mini_orb_particleup_02 "
}

Screen capture:

enter image description here

Toto
  • 19,304
1

I won't be winning any RegEx Golf with this answer, but it works.

Using the guidelines in Dmytro Dzyubak's answer (i.e. search in RegEx mode with ". matches newline" checked), make the following changes:

Find: ^(S[^\r\n]+)(\r?\n?)\{(.*?)\}
Replace: \1\2\{\2\}

Info:
It now ensures that the line preceding the brackets starts with a capital S.
It also catches the line ending and replaces it (so that you don't end up with mixed line endings).
\1 and \2 in the Replace expression refer to the parentheses groups in the Find expression.