WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   SublimeText2 Remove Duplicate (https://www.wowinterface.com/forums/showthread.php?t=49249)

Tactica 05-02-14 07:47 AM

SublimeText2 Remove Duplicate
 
This is a cross post! - Not sure if it belongs in the GAD section...

Just wondering if any other SublimeText 2 users know how to resolve this issue without having to manually delete the repeated/duplicate value:

I have an ungodly amount of lines that need one of the duplicate (1025 and 1151 in this example) values removed.
Code:

s(-1025,1025,{32047, 32048, 32049, 32050, 32051, 32807, 32795},128)
s(1151,1151,{8197, 8176, 8193, 8192, 8175, 31563, 9428, 94044},nil)

I searched around on Stack Overflow and a few other sites and got some major help in regards to other things, but couldn't find anything specific about removing duplicate values in a line/string without screwing up the other values. Any suggestions or plugins?

Cheers!

ravagernl 05-02-14 11:19 AM

Hmm, in a regular expression, it would probably be something along the lines of:
Code:

/(\d+),\1/
and replace with
Code:

\1
http://regex101.com/r/gI4uK9
EDIT: or even: http://regex101.com/r/vB1lW4

Tactica 05-02-14 11:53 AM

Quote:

Originally Posted by ravagernl (Post 292474)
Hmm, in a regular expression, it would probably be something along the lines of:
Code:

/(\d+),\1/
and replace with
Code:

\1

http://regex101.com/r/gI4uK9

You is my hero! THANKS! :D

Tactica 05-03-14 03:27 AM

I don't know if this is even possible with regex/apend without having to do it manually:
Code:

s(895,"Stormshroud Armor",{15058,21278,23073,30362,12966},1544) --Leather
s(-1266,"Stormshroud Armor (Recolor)",{29141,21458,21708},nil) --Leather
s(-166,"Stormshroud Armor (Recolor)",{10153,10149,10147,10145},nil) --Leather
s(-163,"Stormshroud Armor (Recolor)",{8299,8301,8298,8293,8295},nil) --Leather
s(1759,"Battle",{99157,99158,99159,105779,105792},4) --Mail
s(-1764,"Battle (Lookalike)",{105140,104956,105141,105086,105119},nil) --Mail
s(1763,"Battle (Recolor)",{99081,99082,105086,105119},4) --Mail
s(-1762,"Battle (Lookalike)",{105639,105584,105617},nil) --Mail
s(-1761,"Battle (Recolor)",{99404,105584,105617},4) --Mail
s(-1760,"Battle (Lookalike)",{105800,105779,105792},nil) --Mail

I am trying to place the 895/1759 etc. etc. value to all pieces in a matching name/set:
Code:

s(895,"Stormshroud Armor",{15058,21278,23073,30362,12966},1544) --Leather; 895
s(-1266,"Stormshroud Armor (Recolor)",{29141,21458,21708},nil) --Leather; 895
s(-166,"Stormshroud Armor (Recolor)",{10153,10149,10147,10145},nil) --Leather; 895
s(-163,"Stormshroud Armor (Recolor)",{8299,8301,8298,8293,8295},nil) --Leather; 895
s(1759,"Battle",{99157,99158,99159,105779,105792},4) --Mail; 1759
s(-1764,"Battle (Lookalike)",{105141,105086,105119},nil) --Mail 1759
s(-1763,"Battle (Recolor)",{99081,99082,105086,105119},4) --Mail; 1759
s(-1762,"Battle (Lookalike)",{105639,105584,105617},nil) --Mail; 1759
s(-1761,"Battle (Recolor)",{99404,105584,105617},4) --Mail; 1759
s(-1760,"Battle (Lookalike)",{105800,105779,105792},nil) --Mail; 1759


Phanx 05-03-14 05:30 AM

Not sure if there's a pure regex solution (at least one you can drop into a search/replace dialog) but based on your example it looks like all the "base" sets have positive IDs and the "lookalike" sets have negative ones, so you could reduce the amount of copy/pasting you have to do by regex-ing the positive ID to the end, then just copying it to the ID-less lines below it.

Tactica 05-03-14 09:03 AM

Quote:

Originally Posted by Phanx (Post 292491)
...based on your example it looks like all the "base" sets have positive IDs and the "lookalike" sets have negative ones, so you could reduce the amount of copy/pasting you have to do by regex-ing the positive ID to the end, then just copying it to the ID-less lines below it.

True, Find+Select then Find All lines containing just a positive value s(####,"...) would work. Just need to capture the first set of numbers! Tried tinkering a bit and this is as far as I got with the expression:
Quote:

\w[(]\d[0-9]*
This selects s(#### when all I need is the s(####
Using the select line feature would eliminate 708 lines to comment and leave 89 lines to comment! :p

cokedrivers 05-03-14 02:22 PM

I'm not a programmer, so I'm not 100% sure if this will help. But when I'm modifying lua I use Notepad++ it has a find and a find/replace function that make changing every instance of "MOM" to "DAD" simple as clicking the "find next" button then click the "replace" button.

Hope this helps.
Coke

ravagernl 05-03-14 03:04 PM

Quote:

Originally Posted by Tactica (Post 292493)
This selects s(#### when all I need is the s(####
Using the select line feature would eliminate 708 lines to comment and leave 89 lines to comment! :p

Try capturing it, also you can use \d+ instead of \d[0-9]* :) \d+ matches one digit or more.

http://regex101.com/r/mR2fG3

Tactica 05-03-14 03:48 PM

Quote:

Originally Posted by ravagernl (Post 292506)
Try capturing it, also you can use \d+ instead of \d[0-9]* :) \d+ matches one digit or more.

http://regex101.com/r/mR2fG3

I am a lil confuzzled. Sorry if I am such a nub at these expressions... http://regex101.com/r/mR2fG3 = [a-z]\((\d+) and \w[(]\d+ which both capture the same "s(1759" when I need just the "1759" Also, this is for regexp future reference.

Still trying to figure out how to copy all the different line values, i.e. "s(1759", "s(892" etc. etc. throughout the entire ST2 document and then paste them at the end of their respective line. Any suggestion as to the proper method?

EDIT:
Code:

local comment, group
print((([[
s(1759,"B 1",{99168,99157,99158,99159,105779,105792},4)
s(-1764,"B 2 (L)",{105819,105140,104956,105141,105086,105119},nil)
s(-1763,"B 3 (R)",{99086,99080,99081,99082,105086,105119},4)
s(-1762,"B 4 (L)",{105432,105638,105454,105639,105584,105617},nil)
s(-1761,"B 5 (R)",{99406,99402,99403,99404,105584,105617},4)
s(-1760,"B 6 (L)",{105183,105809,105754,105800,105779,105792},nil)
s(1753,"C",{105161,99108,99109,99104,105784,105790},64)
s(-1755,"C (R)",{105410,99352,99353,99354,105597,105598},64)
s(-1754,"C (L)",{105329,105161,105259,105404,105755,105784,105790},nil)
]]):gsub('(s%((.-),"(%w+).-)\n',
  function(line, next_comment, next_group)
      if group ~= next_group then
        group = next_group
        comment = next_comment
      end
      return line..' -- '..comment..'\n'
  end
)))

^ Works somewhat. It matches s(1629,"Plate of the All-Consuming Maw" with the same itemset# (1629) as s(1458,"Plate of Resounding Rings" due to the "Plate" name.

Rainrider 05-03-14 06:24 PM

You might try http://regex101.com/r/bC3wS3 with Phanx suggestion above

Tactica 05-04-14 10:22 AM

I am posting this to share with others for reference and so others could critique the regex I used to accomplish everything. Maybe someone will find this helpful.

Here is the example code:
Code:

s(544,"Ahn'Kahar Blood Hunter's Battlegear",{50118,50789,50762,50812},4)--544
s(-469,"Ahn'Kahar Blood Hunter'sBattlegear(Lookalike)",50413,49952,50071,50000},nil) --544
s(-470,"Ahn'Kahar Blood Hunter's Battlegear (Lookalike)",{51877,51911,51853,51914},nil) --544
s(-471,"Ahn'Kahar Blood Hunter's Battlegear (Lookalike)",{51002,51566,51325,50789},nil) --544
s(-545,"Ahn'Kahar Blood Hunter's Battlegear (Recolor)",{50979,54577,51151,51153,51914,51935},4)  --544
s(-546,"Ahn'Kahar Blood Hunter's Battlegear (Recolor)",{,51289,50655,50688,50711},4) --544

FYI:
  • Find What:
  • Replace With:
All links take you to regex101 examples!
This was done in Sublime Text 2.

------------------------------------------------------------------------------
  1. Remove duplicate id value: s(1234,1234,
    • (\d+),\1
    • \1
    Here


  2. Comment with their respective ID:
    Quote:

    s(1059,"Amani Mail",{,69561,69590,94216},nil) --1059
    s(-1060,"Amani Mail (Recolor)",{33535,94079,94083,94078},nil) --1059
    • s\((?<!\-)(\d+)(.+\n)(?:((?:s\((?=\-).+\d+\n)+)|(s\((?=\-).+))+
    • s($1$2$3$4 --$1


  3. Fix for above which may produce:
    Quote:

    --1059s(1059,"Amani Mail",{,69561,69590,94216},nil) --1059
    • \s?--.+(?=s\()
    Here


  4. To add --####;Mail after:
    Quote:

    --####
    • (--+.*)
    • \1; Cloth
    Here


  5. To find all comments:
    Quote:

    --1234
    • (--+.*)
    • \1
    Same as above, use Find All


  6. Copy s(####) to --Comment; ####
    • ([a-z]\((\d+).*)
    • \1; \2
    Here



  7. To find s(###) not s(-1234
    • \w\(\d
    Here


All times are GMT -6. The time now is 03:06 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI