core/src/main/java/org/jruby/RubyRegexp.java
public final int searchString(ThreadContext context, RubyString str, int pos, boolean reverse) {
        final ByteList strBL = str.getByteList();
        final int beg = strBL.begin();
        int range = beg;

        if (pos > str.size() || pos < 0) {
            context.setLocalMatch(null);

            return -1;
        }

        final Regex reg = preparePattern(str);

        if (!reverse) range += str.size();

        final Matcher matcher = reg.matcher(strBL.unsafeBytes(), beg, beg + strBL.realSize());

        try {
            int result = matcherSearch(context, matcher, beg + pos, range, RE_OPTION_NONE);
            if (result == -1) {
                context.setLocalMatch(null);

                return -1;
            }

            RubyMatchData match = context.getLocalMatch();
            if (match == null || match.used()) {
                match = createMatchData(context, str, matcher, reg);
            } else {
                match.initMatchData(str, matcher, reg);
            }

            match.regexp = this;
            match.infectBy(this);

            context.setLocalMatch(match);

            return result;
        } catch (JOniException je) {
            throw context.runtime.newRegexpError(je.getMessage());
        }
    }
/**
     * Search the given string with this Regexp.
     *
     * MRI: rb_reg_search0 without backref updating
     */
Search the given string with this Regexp.
MRI: rb_reg_search0 without backref updating
Search the given string with this Regexp . MRI : rb_reg_search0 without backref updating
public final int searchString(ThreadContext context, RubyString str, int pos, boolean reverse) {
        final ByteList strBL = str.getByteList();
        final int beg = strBL.begin();
        int range = beg;
        if (pos > str.size() || pos < 0) {
            context.setLocalMatch(null);
            return -1;
        }
        final Regex reg = preparePattern(str);
        if (!reverse) range += str.size();
        final Matcher matcher = reg.matcher(strBL.unsafeBytes(), beg, beg + strBL.realSize());
        try {
            int result = matcherSearch(context, matcher, beg + pos, range, RE_OPTION_NONE);
            if (result == -1) {
                context.setLocalMatch(null);
                return -1;
            }
            RubyMatchData match = context.getLocalMatch();
            if (match == null || match.used()) {
                match = createMatchData(context, str, matcher, reg);
            } else {
                match.initMatchData(str, matcher, reg);
            }
            match.regexp = this;
            match.infectBy(this);
            context.setLocalMatch(match);
            return result;
        } catch (JOniException je) {
            throw context.runtime.newRegexpError(je.getMessage());
        }
    }
public final int searchString ( ThreadContext context , RubyString str , int pos , boolean reverse ) { final ByteList strBL = str . getByteList ( ) ; final int beg = strBL . begin ( ) ; int range = beg ; if ( pos > str . size ( ) || pos < 0 ) { context . setLocalMatch ( null ) ; return - 1 ; } final Regex reg = preparePattern ( str ) ; if ( ! reverse ) range += str . size ( ) ; final Matcher matcher = reg . matcher ( strBL . unsafeBytes ( ) , beg , beg + strBL . realSize ( ) ) ; try { int result = matcherSearch ( context , matcher , beg + pos , range , RE_OPTION_NONE ) ; if ( result == - 1 ) { context . setLocalMatch ( null ) ; return - 1 ; } RubyMatchData match = context . getLocalMatch ( ) ; if ( match == null || match . used ( ) ) { match = createMatchData ( context , str , matcher , reg ) ; } else { match . initMatchData ( str , matcher , reg ) ; } match . regexp = this ; match . infectBy ( this ) ; context . setLocalMatch ( match ) ; return result ; } catch ( JOniException je ) { throw context . runtime . newRegexpError ( je . getMessage ( ) ) ; } }
Search the given string with this Regexp.
Search the given string with this Regexp .