Code:
var %cnt = 1, %ttl = $hget(table,0).item
while %cnt <= %ttl {
  var %item = $hget(table,%cnt).item, %data = $hget(table,%cnt).data
  .hadd -m table %item $reptokcs(%data,$gettok(%data,5,9),Melon,1,9)
  inc %cnt
}


Note: Some of the items in the code are fixed, per your example, if you need something that is more flexible, you can try to work it out yourself and/or post back here and I'll do it up for you tonight.
Additionally, the above code is case sensitive, if you don't want that, remove the cs from $reptokcs

/help $reptok