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 "
}
GordonAitchJay
  • 369
  • 2
  • 8

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
  • 17,001
  • 56
  • 30
  • 41
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.

  • This will also remove `Send{ blah blah}` or `DontSend{ blah blah}` – Toto Jun 28 '19 at 12:47
  • @Toto, this is true. I forgot to put the ^ before the S to ensure that the S was at the beginning of the line. I'll update it. Thanks! (I did mention that it was targeting all lines that start with S in the Info section of my answer, but I see that your answer more precisely answers his question and better explains what is happening. Since he had previously asked a question for this same type of thing, I assumed he was more wanting to learn RegEx and different ways to quickly apply it in Notepad++ than only be able to target those two words.) directly. – UrsineRaven Jun 28 '19 at 13:53
  • @Toto, your answer is a far more thorough and elegant answer. I also didn't realize Notepad++ supported some of those features of RegEx. If I had enough reputation, I'd upvote it. ;) – UrsineRaven Jun 28 '19 at 14:03
  • Thank you :)..... – Toto Jun 28 '19 at 14:04