Match characters in a backward direction
511225
static boolean matchBackward(char[] chars, char[] pattern, int[] cursor) {
    int start = cursor[1] - pattern.length;
    if (start < cursor[0])
      // candidate is too short to possibly match
      return false;
    if (!matchForward(chars, pattern, new int[] {start, cursor[1]}))
      return false;
    // The candidate matches, so reflect that in the cursor
    cursor[1] = start;
    return true;
  }
849051
def findLastCharIndexMatching(text, func):
    
    for i in range(len(text) - 1, -1, -1):
      if func(text[i]):
        return i
758596
def reversed(self):
        """"""
        newpath = [seg.reversed() for seg in self]
        newpath.reverse()
        return Path(*newpath)
1229179
def unmatched(match):
    """"""
    start, end = match.span(0)
    return match.string[:start]+match.string[end:]
1328945
def match(cls, pattern, inverse=False):
        """"""
        string_pattern = pattern
        invert_search = inverse

        class DefinedStringFilter(cls):
            pattern = string_pattern
            inverse = invert_search
        return DefinedStringFilter
713856
function boolMatch(s, matchers) {
    var i, matcher, down = s.toLowerCase();
    matchers = [].concat(matchers);
    for (i = 0; i < matchers.length; i += 1) {
      matcher = matchers[i];
      if (!matcher) continue;
      if (matcher.test && matcher.test(s)) return true;
      if (matcher.toLowerCase() === down) return true;
    }
  }
1356034
def chars_before(chars, match):
    
    if match.start <= 0:
        return True
    return match.input_string[match.start - 1] in chars
498319
def match(self, string):
        """"""
        if self.casesensitive:
            return fnmatch.fnmatch(string, self.pattern)
        else:
            return fnmatch.fnmatch(string.lower(), self.pattern.lower())
695987
def findTextBackward(self, block, column, needle):
        
        if column is not None:
            index = block.text()[:column].rfind(needle)
        else:
            index = block.text().rfind(needle)

        if index != -1:
            return block, index

        for block in self.iterateBlocksBackFrom(block.previous()):
            column = block.text().rfind(needle)
            if column != -1:
                return block, column

        raise ValueError('Not found')
147523
private boolean match(char []a, int aOff, int aLength, char []b)
  {
    int bLength = b.length;

    if (aLength != bLength)
      return false;

    for (int i = aLength - 1; i >= 0; i--) {
      char chA = a[aOff + i];
      char chB = b[i];

      if (chA != chB && chA + 'a' - 'A' != chB) {
        return false;
      }
    }

    return true;
  }
176558
private static int matchesAt(CharSequence text, int offsetInText, CharSequence substring) {
        int len = substring.length();
        int textLength = text.length();
        if (textLength + offsetInText > len) {
            return -1;
        }
        int i = 0;
        for (int j = offsetInText; i < len; ++i, ++j) {
            char pc = substring.charAt(i);
            char tc = text.charAt(j);
            if (pc != tc) return -1;
        }
        return i;
    }
855269
function match(input) {
    let lowerInput = input.toLowerCase();
    let simpleMatch = _simpleMatch(lowerInput);
    let complexMatch = _complexMatch(lowerInput);
    let output = simpleMatch.concat(complexMatch);

    return output;
}
214244
static boolean matchForward(char[] chars, char[] pattern, int[] cursor) {
    if (pattern.length > cursor[1] - cursor[0])
      return false;
    int index = 0;
    while (index < pattern.length)
      if (chars[cursor[0]++] != pattern[index++])
        return false;
    return true;
  }
1234658
def match_alphabet(self, pattern):
    
    s = {}
    for char in pattern:
      s[char] = 0
    for i in range(len(pattern)):
      s[pattern[i]] |= 1 << (len(pattern) - i - 1)
    return s
940305
def _iterateDocumentCharsBackward(self, block, startColumnIndex):
        
        # Chars in the start line
        endTime = time.time() + self._MAX_SEARCH_TIME_SEC
        for columnIndex, char in reversed(list(enumerate(block.text()[:startColumnIndex]))):
            yield block, columnIndex, char
        block = block.previous()

        # Next lines
        while block.isValid():
            for columnIndex, char in reversed(list(enumerate(block.text()))):
                yield block, columnIndex, char

            if time.time() > endTime:
                raise _TimeoutException('Time is over')

            block = block.previous()
324613
def backward_regex regex
      if regex.is_a? Symbol
        regex = @text_patterns[regex]
        raise "Pattern specified #{regex} does not exist in text_patterns " unless regex
      end
      $multiplier = 1 if !$multiplier || $multiplier == 0
      _arr = _getarray
      pos = @curpos || 0 # list does not have curpos
      line = @current_index
      #buff = _arr[line].to_s
      #return unless buff
      # if curpos is at zero , we should be checking previous line !
      $multiplier.times {
        # if at start of line, go to previous line
        if pos == 0
          if @current_index > 0
            line -= 1
            pos = _arr[line].to_s.size
          else
            # we are on first line of file at start
            break
          end
        end
        buff = _arr[line].to_s
        return unless buff
        pos2 = pos - 2
        pos2 = 0 if pos2 < 0
        found = buff.rindex(regex, pos2)
        $log.debug "  backward: pos #{pos} , found #{found}, pos2 = #{pos2} "
        if !found || found == 0
          # if not found, we've lost a counter
          if pos > 0
            pos = 0
          elsif line > 0
            #line -= 1
            #pos = _arr[line].to_s.size
          else
            break
          end
        else
          pos = found + 1
        end
        $log.debug " backward_word: pos #{pos} line #{line} buff: #{buff}"
      }
      $multiplier = 0
      @current_index = line
      @curpos = pos
      ensure_visible
      @repaint_required = true
    end
1043572
private static CharSequence reverse(CharSequence s) {
    int length = s.length();
    if (length <= 1) {
      return s;
    }

    char[] buffer = new char[length];
    buffer[0] = s.charAt(length - 1);

    for (int i = 1; i < length; i++) {
      buffer[i] = s.charAt(length - 1 - i);
      if (Character.isSurrogatePair(buffer[i], buffer[i - 1])) {
        swap(buffer, i - 1, i);
      }
    }

    return new String(buffer);
  }