-
- int sres = seq
- .findPosition(resIndex
- + Integer.parseInt(spaces.elementAt(resIndex)
- .toString()));
- int eres = seq.findPosition(regex.matchedTo()
- - 1
- + Integer.parseInt(spaces
- .elementAt(regex.matchedTo() - 1).toString()));
-
- searchResults.addResult(seq, sres, eres);
+ // if invalid string used, then regex has no matched to/from
+ int sres = seq.findPosition(resIndex + spaces.get(resIndex));
+ int eres = seq.findPosition(regex.matchedTo() - 1
+ + (spaces.get(regex.matchedTo() - 1)));
+ // only add result if not contained in previous result
+ if (lastm == null || (lastm.getSequence() != seq
+ || (!(lastm.getStart() <= sres
+ && lastm.getEnd() >= eres))))
+ {
+ lastm = searchResults.addResult(seq, sres, eres);
+ }