     @scopeName = name ? contentName # TODO: We need special treatment of contentName
 
     if match
-      if (end or @popRule) and @hasBackReferences ?= /\\\d+/.test(match)
+      if (end or @popRule) and @hasBackReferences ?= DigitRegex.test(match)
         @match = match
       else
         @regexSource = match

      else
        match

    resolvedScopeName.replace /\$(\d+)/, (match, index) ->
      capture = captureIndices[parseInt(index)]
      if capture?
        line.substring(capture.start, capture.end)

    for {start, end} in beginCaptureIndices
      beginCaptures.push line[start...end]

    resolvedMatch = @match.replace AllDigitsRegex, (match) ->
      index = parseInt(match[1..])
      _.escapeRegExp(beginCaptures[index] ? "\\#{index}")

