private FindResult findStringByRegularExpression(CharSequence text,
                                                   int startOffset,
                                                   FindModel model,
                                                   VirtualFile file) {
    Matcher matcher = compileRegExp(model, text);
    if (matcher == null) {
      return NOT_FOUND_RESULT;
    }
    try {
      if (model.isForward()) {
        if (matcher.find(startOffset)) {
          if (matcher.end() <= text.length()) {
            return new FindResultImpl(matcher.start(), matcher.end());
          }
        }
        return NOT_FOUND_RESULT;
      }
      else {
        int start = -1;
        int end = -1;
        while (matcher.find() && matcher.end() < startOffset) {
          start = matcher.start();
          end = matcher.end();
        }
        if (start < 0) {
          return NOT_FOUND_RESULT;
        }
        return new FindResultImpl(start, end);
      }
    } catch (StackOverflowError soe) {
      String stringToFind = model.getStringToFind();

      if (!ApplicationManager.getApplication().isHeadlessEnvironment() &&
          ourReportedPatterns.put(stringToFind.hashCode(), Boolean.TRUE) == null) {
        String content = FindBundle.message("notification.content.regular.expression.soe", stringToFind, file.getPresentableUrl());
        LOG.info(content);
        GROUP.createNotification(FindBundle.message("notification.title.regular.expression.failed.to.match"), content, NotificationType.ERROR).notify(myProject);
      }
      return NOT_FOUND_RESULT;
    }
  }
private FindResult findStringByRegularExpression(CharSequence text,
                                                   int startOffset,
                                                   FindModel model,
                                                   VirtualFile file)