     for {start, end} in beginCaptureIndices
       beginCaptures.push line[start...end]
 
-    resolvedMatch = @match.replace /\\\d+/g, (match) ->
+    resolvedMatch = @match.replace AllDigitsRegex, (match) ->
       index = parseInt(match[1..])
       _.escapeRegExp(beginCaptures[index] ? "\\#{index}")
 

    @scopeName = name ? contentName # TODO: We need special treatment of contentName

    if match
      if (end or @popRule) and @hasBackReferences ?= /\\\d+/.test(match)
        @match = match
      else
        @regexSource = match

      else
        match

    resolvedScopeName.replace CaptureIndexRegex, (match, index) ->
      capture = captureIndices[parseInt(index)]
      if capture?
        line.substring(capture.start, capture.end)
