Community
    • Login

    Remove Repeated Words and Symbols

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 1.1k Views
    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
      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
        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
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors