Community
    • Login

    Remove Repeated Words and Symbols

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 1.4k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • kloruklassK Offline
      kloruklass
      last edited by kloruklass

      { } =
      space

      I would like to replace these characters with an underscore, and then remove all the duplicate words.

      For instance, I’d like to change:

      dmg_sm0993_event (summonedtable) 0039-event [damage=hit_defend_fail_se_0039_type=slash_low] [damage_fail_type=defend_fail] {!} {r} {m} {s} {e}
      

      To (both “{ }” and characters inside are not needed.)

      dmg_sm0993_event_summonedtable_0039_damage_hit_defend_fail_se_type_slash_low
      
      1 Reply Last reply Reply Quote 0
      • guy038G Offline
        guy038
        last edited by guy038

        Hello, @kloruklass and All,

        Given your ( uniq ! ) example :

        dmg_sm0993_event (summonedtable) 0039-event [damage=hit_defend_fail_se_0039_type=slash_low] [damage_fail_type=defend_fail] {!} {r} {m} {s} {e}
        

        With the following regex S/R :

        • SEARCH (?-s)[^\w{}\r\n]+(?:\x20*({.+?})|)

        • REPLACE ?1:_

        • Tick the Wrap around option

        • Select the Regular expression search mode

        • Click once, on the Replace All button

        You’ll get this temporary text :

        dmg_sm0993_event_summonedtable_0039_event_damage_hit_defend_fail_se_0039_type_slash_low_damage_fail_type_defend_fail
        

        Now, using this second regex S/R :

        • SEARCH (?i-s)(([a-z0-9]+)_.*)_\2(?:(_)|\R|\z)

        • REPLACE \1?3_

        • Click on the Replace All button, several times, till you see the status line 0 occurrences were replaced in entire file ( IMPORTANT )

        And you’ll get the expected text :

        dmg_sm0993_event_summonedtable_0039_damage_hit_defend_fail_se_type_slash_low
        

        Best Regards

        guy038

        1 Reply Last reply Reply Quote 1

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors