Finds the first occurrence of the pattern in the text.
768537
int indexOf(byte[] data, int dataLength, byte[] pattern, int dataOffset) {
        int[] failure = computeFailure(pattern);
        int j = 0;
        if (data.length == 0)
            return -1;
        //final int dataLength = data.length;
        final int patternLength = pattern.length;
        for (int i = dataOffset; i < dataLength; i++) {
            while (j > 0 && pattern[j] != data[i])
                j = failure[j - 1];
            if (pattern[j] == data[i])
                j++;
            if (j == patternLength)
                return i - patternLength + 1;
        }
        return -1;
    }
754755
def exact_find_in_pattern(fixed_text, cur=0, patterns=PATTERNS):
    """"""
    return [x for x in patterns if (cur + len(x['find']) <= len(fixed_text))
             and x['find'] == fixed_text[cur:(cur + len(x['find']))]]
737768
public static int indexOfIgnoreCase( String text , String needle , int fromIndex )
    {
        int textLen = text.length();
        int needleLen = needle.length();
        
        if (fromIndex >= textLen) return needleLen == 0 ? textLen : -1;
        int i = fromIndex;
        if (i < 0)
        	i = 0;
        if (needleLen == 0) return i;
        
        char first = Character.toUpperCase(needle.charAt(0));
        int max = textLen - needleLen;
        
        startSearchForFirstChar:
        while (true)
        {
            // Look for first character.
            while (i <= max)
            {
                char c = Character.toUpperCase(text.charAt(i));
                if (c != first)
                    i++;
                else
                    break;
            }
            if (i > max) return -1;
            
            // Found first character, now look at the rest of the string
            int j = i + 1;
            int end = j + needleLen - 1;
            int k = 1;
            while (j < end) 
            {
                char c1 = Character.toUpperCase(text.charAt(j++));
                char c2 = Character.toUpperCase(needle.charAt(k++));
                if (c1 != c2) 
                {
                    i++;
                    // Look for str's first char again.
                    continue startSearchForFirstChar;
                }
             }
            
            return i;
        }
    }
990486
public Stream<HString> findAllPatterns(@NonNull Pattern regex) {
      return Streams.asStream(new Iterator<HString>() {
         Matcher m = regex.matcher(HString.this);
         int start = -1;
         int end = -1;

         private boolean advance() {
            if (start == -1) {
               if (m.find()) {
                  start = m.start();
                  end = m.end();
               }
            }
            return start != -1;
         }

         @Override
         public boolean hasNext() {
            return advance();
         }

         @Override
         public HString next() {
            if (!advance()) {
               throw new NoSuchElementException();
            }
            HString sub = substring(start, end);
            start = -1;
            end = -1;
            //If we have tokens expand the match to the overlaping tokens.
            if (document() != null && document().isCompleted(Types.TOKEN)) {
               return union(sub.tokens());
            }
            return sub;
         }
      });
   }
861236
def find_first_match regex #:nodoc:
      @list.each_with_index do |row, ix|
        return ix if !row.match(regex).nil?
      end
      return nil
    end
458047
def search(pattern, text):
    ''
    return re.compile(str(pattern)).search(str(text))
218625
private int findFirst(CharSequence input, int beginIndex, int rewindIndex) {
        int first = -1;
        boolean atomBoundary = true;
        for (int i = beginIndex; i >= rewindIndex; i--) {
            char c = input.charAt(i);
            if (localAtomAllowed(c)) {
                first = i;
                atomBoundary = false;
            } else if (c == '.') {
                if (atomBoundary) {
                    break;
                }
                atomBoundary = true;
            } else {
                break;
            }
        }
        return first;
    }
1081199
def parse_body(self, text):
        """"""
        re_raise = re.findall(r'[ \t]raise ([a-zA-Z0-9_]*)', text)
        if len(re_raise) > 0:
            self.raise_list = [x.strip() for x in re_raise]
            # remove duplicates from list while keeping it in the order
            # in python 2.7
            # stackoverflow.com/questions/7961363/removing-duplicates-in-lists
            self.raise_list = list(OrderedDict.fromkeys(self.raise_list))

        re_yield = re.search(r'[ \t]yield ', text)
        if re_yield:
            self.has_yield = True

        # get return value
        pattern_return = r'return |yield '
        line_list = text.split('\n')
        is_found_return = False
        line_return_tmp = ''

        for line in line_list:
            line = line.strip()

            if is_found_return is False:
                if re.match(pattern_return, line):
                    is_found_return = True

            if is_found_return:
                line_return_tmp += line
                # check the integrity of line
                try:
                    pos_quote = self._find_quote_position(line_return_tmp)

                    if line_return_tmp[-1] == '\\':
                        line_return_tmp = line_return_tmp[:-1]
                        continue

                    self._find_bracket_position(line_return_tmp, '(', ')',
                                                pos_quote)
                    self._find_bracket_position(line_return_tmp, '{', '}',
                                                pos_quote)
                    self._find_bracket_position(line_return_tmp, '[', ']',
                                                pos_quote)
                except IndexError:
                    continue

                return_value = re.sub(pattern_return, '', line_return_tmp)
                self.return_value_in_body.append(return_value)

                is_found_return = False
                line_return_tmp = ''
655671
def FindFirst(params, ctxt, scope, stream, coord, interp):
    
    global FIND_MATCHES_ITER
    FIND_MATCHES_ITER = _find_helper(params, ctxt, scope, stream, coord, interp)

    try:
        first = six.next(FIND_MATCHES_ITER)
        return first.start() + FIND_MATCHES_START_OFFSET
    except StopIteration as e:
        return -1
1281808
def find_matches(text):
    
    """
    path = os.path.expanduser(text)
    if os.path.isdir(path) and not path.endswith('/'):
        return [ text + '/' ]

    pattern = path + '*'
    is_implicit_cwd = not (path.startswith('/') or path.startswith('./'))
    if is_implicit_cwd:
        pattern = './' + pattern
    rawlist = glob.glob(pattern)
    ret = []
    for fname in rawlist:
        if is_implicit_cwd:
            fname = fname[2:]
        if os.path.isdir(fname):
            ret.append(fname + '/')
        else:
            ret.append(fname)
    return ret
528131
def find_first(pattern: str, path: str) -> str:
    
    try:
        return find(pattern, path)[0]
    except IndexError:
        log.critical('''Couldn't find "{}" in "{}"''', pattern, path)
        raise
1260769
public boolean find(Pattern pattern)
    {
        matcher.usePattern(pattern);
        int start = matcher.regionStart();
        if (matcher.find())
        {
            stack.add(new MatchResultImpl(matcher));
            matcher.region(matcher.end(), matcher.regionEnd());
            return true;
        }
        else
        {
            return false;
        }
    }
1018651
public int findFirst(String str, String search) {
        return (str == null || search == null) ? -1 :
            str.indexOf(search);
    }
262790
def find_previous_word_ending(self, count=1, WORD=False):
        
        if count < 0:
            return self.find_next_word_ending(count=-count, WORD=WORD)

        text_before_cursor = self.text_after_cursor[:1] + self.text_before_cursor[::-1]

        regex = _FIND_BIG_WORD_RE if WORD else _FIND_WORD_RE
        iterator = regex.finditer(text_before_cursor)

        try:
            for i, match in enumerate(iterator):
                # Take first match, unless it's the word on which we're right now.
                if i == 0 and match.start(1) == 0:
                    count += 1

                if i + 1 == count:
                    return -match.start(1) + 1
        except StopIteration:
            pass
348048
def find_start_of_previous_word(self, count=1, WORD=False):
        
        # Reverse the text before the cursor, in order to do an efficient
        # backwards search.
        text_before_cursor = self.text_before_cursor[::-1]

        regex = _FIND_BIG_WORD_RE if WORD else _FIND_WORD_RE
        iterator = regex.finditer(text_before_cursor)

        try:
            for i, match in enumerate(iterator):
                if i + 1 == count:
                    return - match.end(1)
        except StopIteration:
            pass
690763
def _find_first_of(line, substrings):
    
    starts = ((line.find(i), i) for i in substrings)
    found = [(i, sub) for i, sub in starts if i != -1]
    if found:
        return min(found)
    else:
        return -1, None
1367793
public static Integer getFirstNumber(CharSequence StringWithNumber) {
		return Convert.toInt(get(PatternPool.NUMBERS, StringWithNumber, 0), null);
	}