   ')': '('
   ']': '['
   '}': '{'
+
+pairRegexes = {}
+for startPair, endPair of startPairMatches
+  pairRegexes[startPair] = new RegExp("[#{_.escapeRegExp(startPair + endPair)}]", 'g')
 
 module.exports =
 class BracketMatcherView extends View


  findMatchingStartPair: (endPairPosition, startPair, endPair) ->
    scanRange = new Range([0, 0], endPairPosition)
    regex = new RegExp("[#{_.escapeRegExp(startPair + endPair)}]", 'g')
    startPairPosition = null
    unpairedCount = 0
    @editor.backwardsScanInBufferRange regex, scanRange, ({match, range, stop}) ->
      switch match[0]
        when startPair
          unpairedCount--


  findMatchingEndPair: (startPairPosition, startPair, endPair) ->
    scanRange = new Range(startPairPosition.translate([0, 1]), @editor.buffer.getEndPosition())
    endPairPosition = null
    unpairedCount = 0
    @editor.scanInBufferRange pairRegexes[startPair], scanRange, ({match, range, stop}) ->
      switch match[0]
        when startPair
          unpairedCount++
