Find search captures recursively.

 @return [Array<Object>] of captures from the expression
 @return [true] in case of no captures in the expression
 @see Fast::Capture
 @see Fast::FindFromArgument
164186
def find_captures(fast = @fast)
      return true if fast == @fast && !captures?(fast)

      case fast
      when Capture then fast.captures
      when Array then fast.flat_map(&method(:find_captures)).compact
      when Find then find_captures(fast.token)
      end
    end
1011745
def recursive_children_removal(found)
      return if found.empty?
      nodes.tap do |ns|
        # found.delete(n.object_id) stops looking for an already found object_id
        ns.delete_if { |n| found.include?(n.object_id) ? found.delete(n.object_id) : false }
        nodes.each do |n|
          n.send(:recursive_children_removal, found) if n.is_a?(Ox::Element)
        end
      end
    end
529460
def matches?(selector)
      selector.each_pair do |key, value|
        return false unless matcher(key, value).matches?(value)
      end
      true
    end
379959
def _docstring_getblocks(self):
        
        #If there are no lines to look at, we have nothing to do here.
        if self.ibuffer[0] == self.ibuffer[1]:
            return []

        lines = self.context.bufferstr[self.ibuffer[0]:self.ibuffer[1]]
        docblock = []
        result = []
        self._doclines = []

        #We need to keep track of the line number for the start of the
        #documentation strings.
        docline = 0
        doclength = 0

        first = self.docparser.RE_DOCS.match(lines[0])
        if first is not None:
            docblock.append(first.group("docstring"))
            docline = self.ibuffer[0]
            self._doclines.append(docline)
            doclength += len(lines[0]) + 1 # + 1 for \n removed by split.

            #We need to search backwards in the main buffer string for
            #additional tags to add to the block
            i = self.ibuffer[0] - 1
            while i > 0:
                current = self.context.bufferstr[i]
                docmatch = self.docparser.RE_DOCS.match(current)
                if docmatch is not None:
                    docblock.append(docmatch.group("docstring"))
                    docline = i
                    doclength += len(current) + 1
                else:
                    break
                i -= 1

        #Reverse the docblock list since we were going backwards and appending.
        if len(docblock) > 0:
            docblock.reverse()

        #Now handle the lines following the first line. Also handle the
        #possibility of multiple, separate blocks that are still valid XML.
        #We have to keep going until we have exceed the operational changes
        #or found the decorating element.
        i = self.ibuffer[0] + 1
        while (i < len(self.context.bufferstr) and 
               (i < self.ibuffer[1] or len(docblock) > 0)):
            line = self.context.bufferstr[i]
            docmatch = self.docparser.RE_DOCS.match(line)
            if docmatch is not None:
                docblock.append(docmatch.group("docstring"))
                doclength += len(line)
                if docline == 0:
                    docline = i
                #Only track actual documentation lines that are within the 
                #operations list of lines.
                if i < self.ibuffer[1]:
                    self._doclines.append(i)

            elif len(docblock) > 0:
                key = self._docstring_key(line)
                result.append((docblock, docline, doclength, key))
                docblock = []
                docline = 0
                doclength = 0

            #We need to exit the loop if we have exceeded the length of
            #the operational changes
            if len(docblock) == 0 and i > self.ibuffer[1]:
                break
            i += 1

        return result
951575
def _find_next regex=@last_regex, start = @search_found_ix, first_time = false
      #raise "No previous search" if regex.nil?
      warn "No previous search" and return if regex.nil?
      #$log.debug " _find_next #{@search_found_ix} : #{@current_index}"
      extra = 1 # first time search on current line, next time skip current line or else we get stuck.
      extra = 0 if first_time
      start ||= 0
      fend = @list.size-1
      if start != fend
        start += extra unless start == fend # used to be +=1 so we don't get stuck in same row
        @last_regex = regex
        @search_start_ix = start
        regex = Regexp.new(regex, Regexp::IGNORECASE) if @search_case
        start.upto(fend) do |ix| 
          row1 = @list[ix].to_s

          # 2011-09-29 crashing on a character F3 in log file
          # 2013-03-20 - 18:25 187compat
          if row1.respond_to? :encode
            row = row1.encode("ASCII-8BIT", :invalid => :replace, :undef => :replace, :replace => "?")
          else
            row = row1
          end

          m=row.match(regex)
          if !m.nil?
            @find_offset = m.offset(0)[0]
            @find_offset1 = m.offset(0)[1]
            ix += (@_header_adjustment || 0)
            @search_found_ix = ix
            return ix 
          end
        end
      end
      fend = start-1
      start = 0
      if @search_wrap
        start.upto(fend) do |ix| 
          row = @list[ix].to_s
          m=row.match(regex)
          if !m.nil?
            @find_offset = m.offset(0)[0]
            @find_offset1 = m.offset(0)[1]
            ix += (@_header_adjustment || 0)
            @search_found_ix = ix
            return ix 
          end
        end
      end
      return nil
    end
1292023
def find_missing(spec_names)
      unless defined? @originals then
        @originals = {}
        each do |full_name, spec|
          @originals[spec.original_name] = spec
        end
      end

      spec_names.find_all { |full_name|
        @originals[full_name].nil?
      }
    end
1341021
def _find_prev regex=@last_regex, start = @search_found_ix, first_time = false
      #TODO the firsttime part, see find_next
      #raise "No previous search" if regex.nil?
      warn "No previous search" and return if regex.nil?
      #$log.debug " _find_prev #{@search_found_ix} : #{@current_index}"
      if start != 0
        start -= 1 unless start == 0
        @last_regex = regex
        @search_start_ix = start
        regex = Regexp.new(regex, Regexp::IGNORECASE) if @search_case
        start.downto(0) do |ix| 
          row = @list[ix].to_s
          m=row.match(regex)
          if !m.nil?
            @find_offset = m.offset(0)[0]
            @find_offset1 = m.offset(0)[1]
            ix += (@_header_adjustment || 0)
            @search_found_ix = ix
            return ix 
          end
        end
      end
      fend = start-1
      start = @list.size-1
      if @search_wrap
        start.downto(fend) do |ix| 
          row = @list[ix].to_s
          m=row.match(regex)
          if !m.nil?
            @find_offset = m.offset(0)[0]
            @find_offset1 = m.offset(0)[1]
            ix += (@_header_adjustment || 0)
            @search_found_ix = ix
            return ix 
          end
        end
      end
      return nil
    end
974304
function _get(refelm, selector)
    {

        function find(elm, selectorFragment)
        {
            var c, results = selectorFragment.id
			?
				((c = ((elm && elm.ownerDocument) || _document).getElementById(selectorFragment.id)) && _isDescendant(c, elm)) ? [c] : []
			:
				toArray(elm.getElementsByTagName(selectorFragment.tag ? selectorFragment.uTag : "*"));
            c = results.length;

            if (c > 0 && (selectorFragment.id || selectorFragment.classes))
            {
                while (c--)
                {
                    if (!_match(results[c], selectorFragment)) results.splice(c, 1)
                }
            }
            return results
        }


        function toArray(nodes)
        {
            try
            {
                return Array.prototype.slice.call(nodes)
            }
            catch (e)
            {
                var arr = [];
                for (var i = 0; i < nodes.length; i++) arr.push(nodes[i]);
                return arr
            }
        }


        function contains(o)
        {
            for (var c = results.length; c--; )
            {
                if (results[c] === o) return _true;
            }
            return _false
        }

        var results = [],
			elements = [refelm],
			selectorFragments = _sel(selector),
			c, lc,
			d, ld,
			e, le,
			fragment,
			elm, elms;

        if (selectorFragments.length == 0) selectorFragments = [{}];

        for (c = 0, lc = selectorFragments.length; c < lc; c++)
        {
            fragment = selectorFragments[c];
            for (d = 0, ld = elements.length; d < ld; d++)
            {
                elm = elements[d];
                switch (fragment.rel)
                {
                    case ">":
                        var children = elm.childNodes;
                        for (e = 0, le = children.length; e < le; e++)
                        {
                            if (_match(children[e], fragment))
                            {
                                results.push(children[e])
                            }
                        }
                        break;

                    case "~":
                        while (elm = elm.nextSibling)
                        {
 							
							if (_match(elm, fragment))
                            {
                                if (contains(elm))
                                {
                                    break;
                                }
                                results.push(elm);
                            }
                        }
                        break;

                    case "+":
                        while ((elm = elm.nextSibling) && elm.nodeType != 1) { };
                        if (elm && _match(elm, fragment))
                        {
                            results.push(elm)
                        }
						
                        break;

                    default:
                        elms = find(elm, fragment);
                        if (c > 0)
                        {
                            for (e = 0, le = elms.length; e < le; e++)
                            {
                                if (!contains(elms[e])) results.push(elms[e])
                            }
                        }
                        else { results = results.concat(elms) }
                        break;
                }
            }

            if (results.length === 0) return [];
            elements = results.splice(0, results.length)

        }
        return elements
    }
725526
def find(no)
            load! if @xrefs.nil?

            ranges = object_ranges

            index = 0
            ranges.each do |range|
                return @xrefs[index + no - range.begin] if range.cover?(no)

                index += range.size
            end

            nil
        end
649133
def find_within(tags, span, pointer)
      puts "--#{span}" if Chronic.debug
      return span if tags.empty?

      head = tags.shift
      head.start = (pointer == :future ? span.begin : span.end)
      h = head.this(:none)

      if span.cover?(h.begin) || span.cover?(h.end)
        find_within(tags, h, pointer)
      end
    end
811955
protected EofMatch findEof(Match matches[]) {
        EofMatch ourEof = null;
        for (int i = 0; i < matches.length; i++) {
            if (matches[i] instanceof EofMatch)
                ourEof = (EofMatch) matches[i];
        }

        if (ourEof == null) {
            // Have to create our own
            ourEof = new EofMatch();
        }

        return ourEof;
    }
774711
function find($selector, $idx=null, $lowercase=false)
	{
		$selectors = $this->parse_selector($selector);
		if (($count=count($selectors))===0) return array();
		$found_keys = array();

		// find each selector
		for ($c=0; $c<$count; ++$c)
		{
			// The change on the below line was documented on the sourceforge code tracker id 2788009
			// used to be: if (($levle=count($selectors[0]))===0) return array();
			if (($levle=count($selectors[$c]))===0) return array();
			if (!isset($this->_[HDOM_INFO_BEGIN])) return array();

			$head = array($this->_[HDOM_INFO_BEGIN]=>1);

			// handle descendant selectors, no recursive!
			for ($l=0; $l<$levle; ++$l)
			{
				$ret = array();
				foreach ($head as $k=>$v)
				{
					$n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k];
					//PaperG - Pass this optional parameter on to the seek function.
					$n->seek($selectors[$c][$l], $ret, $lowercase);
				}
				$head = $ret;
			}

			foreach ($head as $k=>$v)
			{
				if (!isset($found_keys[$k]))
				{
					$found_keys[$k] = 1;
				}
			}
		}

		// sort keys
		ksort($found_keys);

		$found = array();
		foreach ($found_keys as $k=>$v)
			$found[] = $this->dom->nodes[$k];

		// return nth-element or array
		if (is_null($idx)) return $found;
		else if ($idx<0) $idx = count($found) + $idx;
		return (isset($found[$idx])) ? $found[$idx] : null;
	}
1092116
function find(array, exp) {
  return (isArray(array) && isDefined(exp))
    //return the member and not an array like `first`
    ? findInArray(array, $parse(exp), false)
    : array;
}
770796
def find_entities(results)
      document = ::Nokogiri::XML(results.body)
      document.remove_namespaces!
      document.xpath('//entry')
    end
489167
function() {

      var match
      var matchIndex = 0
      var offset = 0
      var regex = this.options.find
      var textAggregation = this.getAggregateText()
      var matches = []
      var self = this
      regex = typeof regex === 'string' ? RegExp(escapeRegExp(regex), 'g') : regex
      matchAggregation(textAggregation)
      function matchAggregation(textAggregation) {
        for (var i = 0, l = textAggregation.length; i < l; ++i) {

          var text = textAggregation[i]
          if (typeof text !== 'string') {
            // Deal with nested contexts: (recursive)
            matchAggregation(text)
            continue
          }

          if (regex.global) {
            while (match = regex.exec(text)) {
              matches.push(self.prepMatch(match, matchIndex++, offset))
            }
          } else {
            if (match = text.match(regex)) {
              matches.push(self.prepMatch(match, 0, offset))
            }
          }

          offset += text.length
        }
      }

      return matches
    }
293179
def extract!( *list )
      list.each do |a|
        if a.is_a?(Hash)
          a.each { |t, o| adapter(t, o) }
        else
          adapter(a)
        end
      end
    end
375093
def find(soup, name=None, attrs=None, recursive=True, text=None, **kwargs):
    
    tags = find_all(
        soup, name, attrs or {}, recursive, text, 1, **kwargs
    )
    if tags:
        return tags[0]