Remove Repeated Words and Symbols
-
{ } =spaceI 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
-
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 line0 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
-