extractInnerMatch(substring, offset, text) {
    for (const innerMatchPattern of INNER_MATCHES) {
      let isFirstMatch = true
      let candidateMatch
      const innerMatchRegExp = new RegExp(innerMatchPattern, 'g')
      while (this.maxTries > 0 && (candidateMatch = innerMatchRegExp.exec(substring)) !== null) {
        if (isFirstMatch) {
          // We should handle any group before this one too.
          const candidate = trimAfterFirstMatch(
            UNWANTED_END_CHAR_PATTERN,
            substring.slice(0, candidateMatch.index)
          )

          const match = this.parseAndVerify(candidate, offset, text)

          if (match) {
            return match
          }

          this.maxTries--
          isFirstMatch = false
        }

        const candidate = trimAfterFirstMatch(UNWANTED_END_CHAR_PATTERN, candidateMatch[1])

        // Java code does `groupMatcher.start(1)` here,
        // but there's no way in javascript to get a `candidate` start index,
        // therefore resort to using this kind of an approximation.
        // (`groupMatcher` is called `candidateInSubstringMatch` in this javascript port)
        // https://stackoverflow.com/questions/15934353/get-index-of-each-capture-in-a-javascript-regex
        const candidateIndexGuess = substring.indexOf(candidate, candidateMatch.index)

        const match = this.parseAndVerify(candidate, offset + candidateIndexGuess, text)
        if (match) {
          return match
        }

        this.maxTries--
      }
    }
  }
Attempts to extract a match from `substring`
if the substring itself does not qualify as a match.