You are here: DEVPPL Forum Programming JavaScript Forum
NOTIFICATIONS
54.098
MEMBERS
15.693
TOPICS
62.271
POSTS
  562
FLASH GAMES
7.740
TUTORIALS
 

Login

E-mail:
Password:

REMOVE (SUBSEQUENT) DUPLICATES IN FIRST PART OF LINE-ITEMS I

0

Loading

REMOVE (SUBSEQUENT) DUPLICATES IN FIRST PART OF LINE-ITEMS I

Postby MT_MANC » Wed Jan 11, 2012 1:37 pm

I'm trying to build a Javascript RemoveDuplicates() that just searches/removes the FIRST PART
(ie upto end of the first " LINEBREAK ") of each line in a sinlge/multi-line LISTBOX user-generated by a web-form.

ORIGINAL LISTBOX ---------------------------
User choices generate listbox that can be single or multi-line in depth => "ShockListRaw" LISTBOX: (here multi-line)

AdjReset RSH_u Run1 LINEBREAK AdjProj RSH_u per 201104-201104 action add cnst 1.00 LINEBREAK Unfix RSH_u per 201104-201104
AdjReset RSH_u Run1 LINEBREAK AdjProj RSH_u per 201201-201201 action add cnst 1.00 LINEBREAK Unfix RSH_u per 201201-201201
DataReset xGP_j Run1 LINEBREAK DataProj xGP_j per 201103-201103 action mult cnst 1.0025 LINEBREAK Fix xGP_j per 201103-201103
DataReset xGP_j Run1 LINEBREAK DataProj xGP_j per 201204-201204 action mult cnst 1.0025 LINEBREAK Fix xGP_j per 201204-201204
DataReset xGP_j Run1 LINEBREAK DataProj xGP_j per 201301-201301 action mult cnst 1.0025 LINEBREAK Fix xGP_j per 201301-201301[*]

NB Variable "RSH_u" or "xGP_j" is called the "Shock Variable" & can potentially be one of 100 string values; this
is the only variable string value in the FIRST PART of each line that I'm concerned with.
NB2 Line numbers are just for illustration/clarity (ie dont occur in LISTBOX)

SEARCH N REPLACE REQUIREMENT ---------------------------
So I need to search for existence & then remove all SUBSEQUENT occurences of 2 strings if they exist:
"AdjReset [Shock Variable] Run1 LINEBREAK" from the FIRST PART of any SUBSEQUENT line where it may occur in "ShockListRaw"
AND
"DataReset [Shock Variable] Run1 LINEBREAK" from the FIRST PART of any SUBSEQUENT line where it may occur in "ShockListRaw"

..and then display cleaned-up output in another LISTBOX eg "ShockListRawClean"
So "AdjReset [Shock Variable] Run1 LINEBREAK" AND "DataReset [Shock Variable] Run1 LINEBREAK" can ONLY occur
ONCE for each [Shock Variable] in "ShockListRawClean"


So in this particular example I need to remove:
Subsequent occurrences of "AdjReset RSH_u Run1 LINEBREAK " ie on Line 2
AND
Subsequent occurrences of "DataReset xGP_j Run1 LINEBREAK " ie on Line 4 & Line 5

REQUIRED CLEANED OUTPUT ---------------------------
"ShockListRawClean" LISTBOX:

AdjReset RSH_u Run1 LINEBREAK AdjProj RSH_u per 201104-201104 action add cnst 1.00 LINEBREAK Unfix RSH_u per 201104-201104
AdjProj RSH_u per 201201-201201 action add cnst 1.00 LINEBREAK Unfix RSH_u per 201201-201201
DataReset xGP_j Run1 LINEBREAK DataProj xGP_j per 201103-201103 action mult cnst 1.0025 LINEBREAK Fix xGP_j per 201103-201103
DataProj xGP_j per 201103-201103 action mult cnst 1.0025 LINEBREAK Fix xGP_j per 201103-201103
DataProj xGP_j per 201301-201301 action mult cnst 1.0025 LINEBREAK Fix xGP_j per 201301-201301[*]

Forum search saw nothing this specific.
I cannot use my standard RemoveDuplicates() as "ShockListRaw" Lines 1 & 2 Lines are NOT identical; Lines 3,4 & 5 are NOT identical

Any thoughts/help appreciated; most kind.
MT_MANC
 
Reputation: 0
Posts: 5
Joined: Mon Mar 31, 2008 9:11 pm
Highscores: 0
Arcade winning challenges: 0

REMOVE (SUBSEQUENT) DUPLICATES IN FIRST PART OF LINE-ITEMS I - Sponsored results

Sponsored results

Login to get rid of ads

 

cron
^ Back to Top