getWordsMatchRange(regex) {
    var endPoint = this.getEndPoint();

    var startPoint = dom.prevPointUntil(endPoint, function(point) {
      if (!dom.isCharPoint(point) && !dom.isSpacePoint(point)) {
        return true;
      }
      var rng = new WrappedRange(
        point.node,
        point.offset,
        endPoint.node,
        endPoint.offset
      );
      var result = regex.exec(rng.toString());
      return result && result.index === 0;
    });

    var rng = new WrappedRange(
      startPoint.node,
      startPoint.offset,
      endPoint.node,
      endPoint.offset
    );

    var text = rng.toString();
    var result = regex.exec(text);

    if (result && result[0].length === text.length) {
      return rng;
    } else {
      return null;
    }
  }
returns range for words before cursor that match with a Regex

example:
 range: 'hi @Peter Pan'
 regex: '/@[a-z ]+/i'
 return range: '@Peter Pan'

@param {RegExp} [regex]
@return {WrappedRange|null}