services/annotators/annotateLib.js
function rangesFromMatches(word, text, selector) {
  var ret = [], match;
  var re = new RegExp('\\b'+word+'\\b', 'gi');
  while ((match = re.exec(text)) !== null) {
    GLOBAL.debug(text.length, text.substring(0, 10), word, match.index, text.substr(match.index, word.length));
     ret.push(annoLib.createRange({exact: text.substr(match.index, word.length), offset: match.index, selector: selector}));
  }
  return ret;
}
function rangesFromMatches(word, text, selector) {
  var ret = [], match;
  var re = new RegExp('\\b'+word+'\\b', 'gi');
  while ((match = re.exec(text)) !== null) {
    GLOBAL.debug(text.length, text.substring(0, 10), word, match.index, text.substr(match.index, word.length));
     ret.push(annoLib.createRange({exact: text.substr(match.index, word.length), offset: match.index, selector: selector}));
  }
  return ret;
}
function rangesFromMatches ( word , text , selector ) { var ret = [ ] , match ; var re = new RegExp ( '\\b' + word + '\\b' , 'gi' ) ; while ( ( match = re . exec ( text ) ) !== null ) { GLOBAL . debug ( text . length , text . substring ( 0 , 10 ) , word , match . index , text . substr ( match . index , word . length ) ) ; ret . push ( annoLib . createRange ( { exact : text . substr ( match . index , word . length ) , offset : match . index , selector : selector } ) ) ; } return ret ; }
convert instances of a match to ranges
convert instances of a match to ranges