- // debug
- /*
- * for (int s = 0; s <= rg.numSubs(); s++) {
- * System.err.println("Sub " + s + " : " + rg.matchedFrom(s) +
- * " : " + rg.matchedTo(s) + " : '" + rg.stringMatched(s) + "'");
- * }
- */
- // try to collate subgroup matches
- StringBuffer subs = new StringBuffer();
- // have to loop through submatches, collating them at top level
- // match
- int s = 0; // 1;
- while (s <= ns)
- {
- if (s + 1 <= ns && rg.matchedTo(s) > -1
- && rg.matchedTo(s + 1) > -1
- && rg.matchedTo(s + 1) < rg.matchedTo(s))
- {
- // s is top level submatch. search for submatches enclosed by
- // this one
- int r = s + 1;
- StringBuffer rmtch = new StringBuffer();
- while (r <= ns && rg.matchedTo(r) <= rg.matchedTo(s))
- {
- if (rg.matchedFrom(r) > -1)
- {
- rmtch.append(rg.stringMatched(r));
- }
- r++;
- }
- if (rmtch.length() > 0)
- {
- subs.append(rmtch); // simply concatenate
- }
- s = r;
- }
- else
- {
- if (rg.matchedFrom(s) > -1)
- {
- subs.append(rg.stringMatched(s)); // concatenate
- }
- s++;
- }
- }
- thematches[pass].append(subs);
- }
- }
- }
- else
- {
- // are we only supposed to take regex matches ?
- if (!onlyIfMatches)
- {
- thismatched[sq] |= true;
- urllength += idseq[pass][sq].length(); // tot up length
- if (createFullUrl)
- {
- thematches[pass] = new StringBuffer(idseq[pass][sq]); // take
- // whole
- // string -
- // regardless - probably not a
- // good idea!
- /*
- * TODO: do some boilerplate trimming of the fields to make them
- * sensible e.g. trim off any 'prefix' in the id string (see
- * UrlLink for the below) - pre 2.4 Jalview behaviour if
- * (idstring.indexOf("|") > -1) { idstring =
- * idstring.substring(idstring.lastIndexOf("|") + 1); }
- */