   enclosed: true
   pair: null
 
+  getPattern: ->
+    pairRegexp = @pair.map(_.escapeRegExp).join('|')
+    ///#{pairRegexp}///g
+
   # Return 'open' or 'close'
-  getPairState: (pair, matchText, range) ->
-    [openChar, closeChar] = pair
+  getPairState: (matchText, range) ->
+    [openChar, closeChar] = @pair
     if openChar is closeChar
       @pairStateInBufferRange(range, openChar)
     else
-      ['open', 'close'][pair.indexOf(matchText)]
+      ['open', 'close'][@pair.indexOf(matchText)]
 
   pairStateInBufferRange: (range, char) ->
     text = getTextToPoint(@editor, range.end)

      when 'close'
        scanFunc = 'scanInBufferRange'
        scanRange = rangeToEndOfFileFromPoint(from)
    pairRegexp = pair.map(_.escapeRegExp).join('|')
    pattern = ///#{pairRegexp}///g

    found = null # We will search to fill this var.
    state = {open: [], close: []}

    @editor[scanFunc] pattern, scanRange, ({matchText, range, stop}) =>
      {start, end} = range
      return stop() if (not allowNextLine) and (from.row isnt start.row)
      return if @isEscapedCharAtPoint(start)

      pairState = @getPairState(pair, matchText, range)
      oppositeState = if pairState is 'open' then 'close' else 'open'
      if pairState is which
        openRange = state[oppositeState].pop()

  ]

  getRangeBy: (klass, selection) ->
    @new(klass, {@inner}).getRange(selection, @enclosed)

  getRanges: (selection) ->
    (range for klass in @member when (range = @getRangeBy(klass, selection)))
