Example usage for java.lang String regionMatches

List of usage examples for java.lang String regionMatches

Introduction

In this page you can find the example usage for java.lang String regionMatches.

Prototype

public boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) 

Source Link

Document

Tests if two string regions are equal.

Usage

From source file:FilenameUtils.java

/**
 * Checks if one string ends with another using the case-sensitivity rule.
 * <p>//from   ww  w. j  ava 2 s .c  o  m
 * This method mimics {@link String#endsWith} but takes case-sensitivity
 * into account.
 * 
 * @param str  the string to check, not null
 * @param end  the end to compare against, not null
 * @return true if equal using the case rules
 * @throws NullPointerException if either string is null
 */
public boolean checkEndsWith(String str, String end) {
    int endLen = end.length();
    return str.regionMatches(!sensitive, str.length() - endLen, end, 0, endLen);
}

From source file:ubic.gemma.core.loader.expression.geo.GeoFamilyParser.java

private boolean startsWithIgnoreCase(String string, String pattern) {
    // it will never be the same string.
    return string.regionMatches(true, 0, pattern, 0, pattern.length());
}

From source file:edu.harvard.iq.dvn.ingest.statdataio.impl.plugins.spss.SPSSFileReader.java

private void getSPSScommandLines(BufferedInputStream cardStream) throws IOException {
    dbgLog.fine("start dividing SPSS data definition file");
    int counter = 0;

    BufferedReader rd = new BufferedReader(new InputStreamReader(cardStream));
    String line = null;/*ww w  .j  a v a  2 s. c o  m*/
    String linesCombined = null;
    String commandHead = "";
    boolean commandTerminated = false;

    List<String> SPSScommands = new ArrayList<String>();

    while ((line = rd.readLine()) != null) {
        // chop all blanks at the end, replace with a single whitespace:

        line = line.replaceFirst("[ \t\n]*$", " ");

        // skip blank, and similar lines:

        if (line.equals(" ") || line.startsWith("comment") || line.startsWith("finish")
                || line.matches("^[ \t]*.$")) {
            dbgLog.fine("skipping line");
        } else if (line.startsWith(" ") || line.startsWith("\t") || line.startsWith(".")) {
            // continuation of a wrapped line.

            if (linesCombined == null) {
                throw new IOException("Illegal entry: line " + line
                        + " starts with a white space, but does not appear within a defined SPSS command block");
            }

            if (line.matches("^[ \t]*\\. *")) {
                // command termination
                SPSScommands.add(linesCombined);
                linesCombined = null;
            } else {
                line = line.replaceAll("^[ \t]*", "");
                linesCombined = linesCombined + line;
            }

        } else {
            // a new command line:
            if (linesCombined != null) {
                throw new IOException("line " + line + ": bad formatting; (command " + commandHead
                        + " not terminated properly?)");
            }

            if (line.matches("^[Nn]\\w* [Oo]\\w* [Cc].*")) {
                // looks like the "Number of Cases" command; 
                // special case -- doesn't need to be terminated by 
                // the "." -- which means we can put it directly 
                // on the command stack:

                SPSScommands.add(line);

            } else {
                commandHead = line;
                linesCombined = commandHead;
            }

        }
    }

    rd.close();

    if (linesCombined != null) {
        throw new IOException(
                "Illegal Control Card Syntax: command " + commandHead + " not terminated properly.");
    }

    String regexCommandLine = "^(\\w+?)\\s+?(\\w+)(.*)";
    Pattern patternCommandLine = Pattern.compile(regexCommandLine);

    for (int i = 0; i < SPSScommands.size(); i++) {
        String commandLine = SPSScommands.get(i);

        // Note that SPSS commands are not case-sensitive.

        String command1 = null;
        String command2 = null;
        String rest = null;

        Matcher commandMatcher = patternCommandLine.matcher(commandLine);

        if (commandMatcher.find()) {
            command1 = commandMatcher.group(1);
            command2 = commandMatcher.group(2);
            rest = commandMatcher.group(3);
        }

        dbgLog.fine("command1: " + command1);
        dbgLog.fine("command2: " + command2);
        dbgLog.fine("rest: " + rest);

        // TODO: code below executed only if rest != null -- ?

        // DATA LIST:

        if (command1 != null && command2 != null && command1.regionMatches(true, 0, "data", 0, 4)
                && command2.regionMatches(true, 0, "list", 0, 4)) {

            if (rest != null) {
                rest = rest.trim();
                dbgLog.fine("saving " + rest + " as a DataList command");

                if (commandStrings.get("DataList") == null) {
                    commandStrings.put("DataList", rest);
                } else {
                    commandStrings.put("DataList", commandStrings.get("DataList") + "/" + rest);
                }
            }

            // VARIABLE LABELS:    

        } else if (command1 != null && command2 != null && command1.regionMatches(true, 0, "var", 0, 3)
                && command2.regionMatches(true, 0, "lab", 0, 3)) {

            if (rest != null) {
                rest = rest.trim();

                if (rest.length() > 0 && rest.substring(rest.length() - 1).equals(".")) {
                    rest = rest.substring(0, rest.length() - 1);
                }
                dbgLog.fine("saving " + rest + " as a VarLabel command");
                if (commandStrings.get("VarLabel") == null) {
                    commandStrings.put("VarLabel", rest);
                } else {
                    commandStrings.put("VarLabel", commandStrings.get("VarLabel") + " " + rest);
                }

            }

            // VALUE LABELS:

        } else if (command1 != null && command2 != null && command1.regionMatches(true, 0, "val", 0, 3)
                && command2.regionMatches(true, 0, "lab", 0, 3)) {

            if (rest != null) {
                rest = rest.trim();

                if (rest.length() > 0 && rest.substring(rest.length() - 1).equals(".")) {
                    rest = rest.substring(0, rest.length() - 2);
                }
                if (rest.length() > 0 && rest.substring(rest.length() - 1).equals("/")) {
                    rest = rest.substring(0, rest.length() - 2);
                }

                dbgLog.fine("saving " + rest + "/ as a ValLabel command");
                if (commandStrings.get("ValLabel") == null) {
                    commandStrings.put("ValLabel", rest + "/");
                } else {
                    commandStrings.put("ValLabel", commandStrings.get("ValLabel") + rest + "/");
                }
            }

            // MISSING VALUES: 

        } else if (command1 != null && command2 != null && command1.regionMatches(true, 0, "mis", 0, 3)
                && command2.regionMatches(true, 0, "val", 0, 3)) {

            if (rest != null) {
                rest = rest.trim();

                if (rest.length() > 0 && rest.substring(rest.length() - 1).equals(".")) {
                    rest = rest.substring(0, rest.length() - 2);
                }

                // TODO:
                // Find out if converting these .toUpperCase() is the
                // right thing to do.

                dbgLog.fine("saving " + rest.toUpperCase() + " as the " + i + "-th MisValue command");

                if (commandStrings.get("MisValue") == null) {
                    commandStrings.put("MisValue", rest);
                } else {
                    commandStrings.put("MisValue", commandStrings.get("MisValue") + " " + rest.toUpperCase());
                }

            }

            // NUMBER OF CASES: (optional -- may not be present)

        } else if (command1 != null && command2 != null && command1.regionMatches(true, 0, "n", 0, 1)
                && command2.regionMatches(true, 0, "of", 0, 2)) {
            if (rest != null) {
                rest = rest.trim();

                if (rest.regionMatches(true, 0, "cases", 0, 5)) {
                    rest = rest.substring(5);
                    rest = rest.trim();
                    String regexNumberOfCases = "^([0-9]*)";
                    Pattern patternNumberOfCases = Pattern.compile(regexNumberOfCases);
                    Matcher casesMatcher = patternNumberOfCases.matcher(rest);

                    if (casesMatcher.find()) {
                        setCaseQnty(Integer.valueOf(casesMatcher.group(1)));
                        smd.getFileInformation().put("caseQnty", getCaseQnty());
                        dbgLog.fine("Number of cases found: " + getCaseQnty());
                    }
                }
            }

        } else {
            throw new IOException("Unsupported or illegal command: " + command1 + " (" + commandLine + ")");
        }

        // also:
        // RECODE?
        // FORMATS?

    }

}

From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java

public JPanel createList() {
    JPanel p = new JPanel(new BorderLayout());
    final VFSJFileChooser fileChooser = getFileChooser();
    final JList aList = new JList() {
        @Override//w w  w  .  ja  va 2  s  .co  m
        public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
            ListModel model = getModel();
            int max = model.getSize();

            if ((prefix == null) || (startIndex < 0) || (startIndex >= max)) {
                throw new IllegalArgumentException();
            }

            // start search from the next element before/after the selected element
            boolean backwards = (bias == Position.Bias.Backward);

            for (int i = startIndex; backwards ? (i >= 0) : (i < max); i += (backwards ? (-1) : 1)) {
                String filename = fileChooser.getName((FileObject) model.getElementAt(i));

                if (filename.regionMatches(true, 0, prefix, 0, prefix.length())) {
                    return i;
                }
            }

            return -1;
        }
    };

    aList.setCellRenderer(new FileRenderer());
    aList.setLayoutOrientation(JList.VERTICAL_WRAP);

    // 4835633 : tell BasicListUI that this is a file list
    aList.putClientProperty("List.isFileList", Boolean.TRUE);

    if (listViewWindowsStyle) {
        aList.addFocusListener(repaintListener);
    }

    updateListRowCount(aList);

    getModel().addListDataListener(new ListDataListener() {
        public void intervalAdded(ListDataEvent e) {
            updateListRowCount(aList);
        }

        public void intervalRemoved(ListDataEvent e) {
            updateListRowCount(aList);
        }

        public void contentsChanged(ListDataEvent e) {
            if (isShowing()) {
                clearSelection();
            }

            updateListRowCount(aList);
        }
    });

    getModel().addPropertyChangeListener(this);

    if (fileChooser.isMultiSelectionEnabled()) {
        aList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    } else {
        aList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }

    aList.setModel(getModel());

    aList.addListSelectionListener(createListSelectionListener());
    aList.addMouseListener(getMouseHandler());

    JScrollPane scrollpane = new JScrollPane(aList);

    if (listViewBackground != null) {
        aList.setBackground(listViewBackground);
    }

    if (listViewBorder != null) {
        scrollpane.setBorder(listViewBorder);
    }

    p.add(scrollpane, BorderLayout.CENTER);

    return p;
}

From source file:ubic.gemma.loader.expression.geo.GeoFamilyParser.java

/**
 * @param line/*from   w w w  .j a  v a2  s.c om*/
 * @param string
 * @return
 */
private boolean startsWithIgnoreCase(String string, String pattern) {
    // it will never be the same string.
    return string.regionMatches(true, 0, pattern, 0, pattern.length());
}

From source file:org.agnitas.beans.impl.MailingImpl.java

private Vector<String> scanForComponents(String aText1, ApplicationContext con,
        Set<MailingComponent> componentsToAdd) {
    Vector<String> addComps = new Vector<String>();
    String aText = null;
    String aLink = null;//w  w w  .j  a  v a2 s  .  c o m
    int startMatch = 0;
    int endMatch = 0;
    MailingComponent tmpComp = null;

    if (aText1 == null) {
        return addComps;
    }

    try {
        aText = aText1.toLowerCase();
        Pattern aRegExp = Pattern.compile("https?://[0-9A-Za-z_.+-]+(:[0-9]+)?(/[^ \t\n\r<>\")]*)?");
        Matcher aMatch = aRegExp.matcher(aText);
        while (true) {
            if (!aMatch.find(endMatch)) {
                break;
            }
            startMatch = aMatch.start();
            endMatch = aMatch.end();
            if (aText.regionMatches(false, startMatch - 5, "src=\"", 0, 5)
                    || aText.regionMatches(false, startMatch - 4, "src=", 0, 4)
                    || aText.regionMatches(false, startMatch - 11, "background=", 0, 11)
                    || aText.regionMatches(false, startMatch - 12, "background=\"", 0, 12)) {
                aLink = aText1.substring(startMatch, endMatch);

                tmpComp = (MailingComponent) con.getBean("MailingComponent");
                tmpComp.setCompanyID(companyID);
                tmpComp.setMailingID(this.id);
                tmpComp.setComponentName(aLink);
                tmpComp.setType(MailingComponentImpl.TYPE_IMAGE);
                if (!components.containsKey(aLink)) {
                    tmpComp.loadContentFromURL();
                    if (tmpComp.getMimeType().startsWith("image")) {
                        //                     addComponent(tmpComp);      // We will do that later
                        componentsToAdd.add(tmpComp);
                    }
                } else {
                    tmpComp = (MailingComponent) this.components.get(aLink);
                }
                if (tmpComp.getMimeType().startsWith("image")) {
                    addComps.add(aLink);
                }
            }
        }

    } catch (Exception e) {
        logger.error("scanForComponents", e);
    }

    return addComps;
}

From source file:de.zib.scalaris.examples.wikipedia.bliki.WikiServlet.java

/**
 * Shows a page containing a list of article names.
 * //from  ww w.j a va2s  .c om
 * @param request
 *            the request of the current operation
 * @param response
 *            the response of the current operation
 * @param result
 *            result from reading the page list
 * @param connection
 *            connection to the database
 * @param page
 *            the bean for the page
 * 
 * @throws IOException
 * @throws ServletException
 */
private void handleViewSpecialPageList(HttpServletRequest request, HttpServletResponse response,
        ValueResult<List<NormalisedTitle>> result, Connection connection, WikiPageListBean page)
        throws ServletException, IOException {
    if (result.success) {
        final TreeSet<String> pageList = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
        MyWikiModel.denormalisePageTitles(result.value, namespace, pageList);
        page.setNotice(getParam_notice(request));
        String nsPrefix = namespace.getNamespaceByNumber(page.getNamespaceId());
        if (!nsPrefix.isEmpty()) {
            nsPrefix += ":";
        }
        final String prefix = nsPrefix + page.getPrefix();
        final String from = page.getFromPage();
        final String fullFrom = nsPrefix + page.getFromPage();
        final String to = page.getToPage();
        final String fullTo = nsPrefix + page.getToPage();
        final String search = page.getSearch().toLowerCase();
        final String searchTitle = MyWikiModel.normaliseName(page.getSearch());
        boolean foundMatch = false;
        if (!prefix.isEmpty() || !from.isEmpty() || !to.isEmpty() || !search.isEmpty()) {
            // only show pages with this prefix:
            for (Iterator<String> it = pageList.iterator(); it.hasNext();) {
                final String cur = it.next();
                // case-insensitive "startsWith" check:
                if (!cur.regionMatches(true, 0, prefix, 0, prefix.length())) {
                    it.remove();
                } else if (!from.isEmpty() && cur.compareToIgnoreCase(fullFrom) <= 0) {
                    it.remove();
                } else if (!to.isEmpty() && cur.compareToIgnoreCase(fullTo) > 0) {
                    it.remove();
                } else if (!search.isEmpty() && !cur.toLowerCase().contains(search)) {
                    it.remove();
                } else if (!search.isEmpty() && cur.equals(searchTitle)) {
                    foundMatch = true;
                }
            }
        }
        page.setPages(pageList);
        page.setFoundFullMatch(foundMatch);
        page.setWikiTitle(siteinfo.getSitename());
        page.setWikiNamespace(namespace);

        forwardToPageJsp(request, response, connection, page, "pageSpecial_pagelist.jsp");
    } else {
        if (result.connect_failed) {
            setParam_error(request, "ERROR: DB connection failed");
        } else {
            setParam_error(request, "ERROR: page list unavailable");
            addToParam_notice(request, "error: unknown error getting page list for " + page.getTitle()
                    + ": <pre>" + result.message + "</pre>");
        }
        showEmptyPage(request, response, connection, page);
        return;
    }
    page.setError(getParam_error(request));
    page.setTitle(page.getTitle());
}

From source file:org.agnitas.beans.impl.MailingImpl.java

@Override
public Vector<String> scanForLinks(String aText1, ApplicationContext con) {
    String aLink = null;//from www . j  a v  a  2 s.  c  o m
    int start = 0;
    int end = 0;
    MailingComponent tmpComp = null;
    TrackableLink trkLink = null;
    Vector<String> addedLinks = new Vector<String>();

    if (aText1 == null) {
        return addedLinks;
    }

    TagDetails aDetail = (TagDetails) con.getBean("TagDetails");
    aDetail.setTagName("agnPROFILE");
    aText1 = aText1.replaceAll("\\[agnPROFILE\\]",
            AgnTagUtils.processTag(aDetail, 0, con, id, mailinglistID, companyID));

    aDetail.setTagName("agnUNSUBSCRIBE");
    aText1 = aText1.replaceAll("\\[agnUNSUBSCRIBE\\]",
            AgnTagUtils.processTag(aDetail, 0, con, id, mailinglistID, companyID));

    try {
        if ((aDetail = getFormTag(aText1, "agnFORM", 0, "[", "]", con)) != null) {
            aDetail.setTagName("agnFORM");
            int beginIndex = aDetail.getFullText().indexOf('"') + 1;
            int endIndex = aDetail.getFullText().indexOf('"', beginIndex);
            aDetail.setName(aDetail.getFullText().substring(beginIndex, endIndex));
            aText1 = aText1.replaceAll("\\[agnFORM name=\".*?\"\\]",
                    AgnTagUtils.processTag(aDetail, 0, con, id, mailinglistID, companyID));
        }
    } catch (Exception e) {
        logger.error("scanForLinks", e);
    }

    try {
        Pattern aRegExp = Pattern.compile("https?://[0-9A-Za-z_.+-]+(:[0-9]+)?(/[^ \t\n\r<>\")]*)?");
        Matcher aMatch = aRegExp.matcher(aText1);
        while (true) {
            if (!aMatch.find(end)) {
                break;
            }
            start = aMatch.start();
            end = aMatch.end();

            try {
                if ((start == 0) || aText1.regionMatches(false, start - 5, "src=\"", 0, 5)
                        || aText1.regionMatches(false, start - 4, "src=", 0, 4)
                        || aText1.regionMatches(false, start - 11, "background=", 0, 11)
                        || aText1.regionMatches(false, start - 12, "background=\"", 0, 12)) {
                    aLink = aText1.substring(start, end);
                    if (!components.containsKey(aLink) && !trackableLinks.containsKey(aLink)) {
                        tmpComp = (MailingComponent) con.getBean("MailingComponent");
                        tmpComp.setCompanyID(companyID);
                        tmpComp.setMailingID(id);
                        tmpComp.setComponentName(aLink);
                        tmpComp.setType(MailingComponent.TYPE_IMAGE);
                        tmpComp.loadContentFromURL();
                        if (!tmpComp.getMimeType().startsWith("image")) {
                            // if(start == 0) {
                            // aLink = aText1.substring(start, end);
                            if (!trackableLinks.containsKey(aLink)) {
                                trkLink = (TrackableLink) con.getBean("TrackableLink");

                                trkLink.setCompanyID(this.companyID);
                                trkLink.setFullUrl(aLink);
                                trkLink.setMailingID(this.id);
                                trkLink.setUsage(TrackableLink.TRACKABLE_TEXT_HTML);
                                trkLink.setActionID(0);

                                trackableLinks.put(aLink, trkLink);
                            }
                            // }
                        }
                    }
                    addedLinks.add(aLink);
                } else {
                    aLink = aText1.substring(start, end);
                    if (!trackableLinks.containsKey(aLink)) {
                        trkLink = (TrackableLink) con.getBean("TrackableLink");
                        trkLink.setCompanyID(this.companyID);
                        trkLink.setFullUrl(aLink);
                        trkLink.setMailingID(this.id);
                        trkLink.setUsage(TrackableLink.TRACKABLE_TEXT_HTML);
                        trkLink.setActionID(0);
                        trackableLinks.put(aLink, trkLink);
                    }
                    addedLinks.add(aLink);
                }
            } catch (Exception e) {
                logger.error("scanForLinks: Error processing link", e);
            }
        }

    } catch (Exception e) {
        logger.error("scanForLinks: error processing links", e);
    }

    return addedLinks;
}

From source file:focusedCrawler.util.parser.PaginaURL.java

/**
 * Declara\uFFFD\uFFFDo do M\uFFFDtodo//from ww w . j a  va  2 s .  c  om
 *
 *
 * @param base
 * @param link
 *
 * @return
 *
 * @throws MalformedURLException
 *
 * @see
 */
protected URL parseLink(URL base, String link) throws MalformedURLException {
    String original = link;
    int i, limit, c;
    int start = 0;
    String newProtocol = null;
    boolean aRef = false;
    String protocol = null;
    String host = null;
    int port = -1;
    String file = null;
    String ref = null;

    try {
        limit = link.length();

        while ((limit > 0) && (link.charAt(limit - 1) <= ' ')) {
            limit--; // eliminate trailing whitespace
        }

        while ((start < limit) && (link.charAt(start) <= ' ')) {
            start++; // eliminate leading whitespace
        }

        if (link.regionMatches(true, start, "url:", 0, 4)) {
            start += 4;
        }

        if (start < link.length() && link.charAt(start) == '#') {

            /*
             * we're assuming this is a ref relative to the context URL.
             * This means protocols cannot start w/ '#', but we must parse
             * ref URL's like: "hello:there" w/ a ':' in them.
             */
            aRef = true;
        }

        for (i = start; !aRef && (i < limit) && ((c = link.charAt(i)) != '/'); i++) {
            if (c == ':') {
                newProtocol = link.substring(start, i).toLowerCase();
                start = i + 1;

                break;
            }
        }

        // Only use our context if the protocols match.
        if ((base != null) && ((newProtocol == null) || newProtocol.equals(base.getProtocol()))) {
            protocol = base.getProtocol();
            host = base.getHost();
            port = base.getPort();
            file = base.getFile();
        } else {
            protocol = newProtocol;
        }

        if (protocol == null) {
            throw new MalformedURLException("no protocol: " + original);
        }

        // if ((handler = getURLStreamHandler(protocol)) == null) {
        // throw new MalformedURLException("unknown protocol: "+protocol);
        // }
        i = link.indexOf('#', start);

        if (i >= 0) {
            ref = link.substring(i + 1, limit);
            limit = i;
        }

        // if ("http".equals(protocol)) return parseURL(protocol, host, port, file, ref, link, start, limit);
        if ("http".equals(protocol)) {
            return parseURL(protocol, host, port, file, null, link, start, limit);
        } else {
            return new URL(base, link);
        }
    } catch (MalformedURLException e) {
        throw e;
    } catch (Exception e) {
        throw new MalformedURLException(original + ": " + e);
    }
}

From source file:com.test.stringtest.StringUtils.java

/**
 * <p>Case in-sensitive find of the last index within a String
 * from the specified position.</p>
 *
 * <p>A <code>null</code> String will return <code>-1</code>.
 * A negative start position returns <code>-1</code>.
 * An empty ("") search String always matches unless the start position is negative.
 * A start position greater than the string length searches the whole string.</p>
 *
 * <pre>//from   w  ww.  ja va2  s  .  c  o  m
 * StringUtils.lastIndexOfIgnoreCase(null, *, *)          = -1
 * StringUtils.lastIndexOfIgnoreCase(*, null, *)          = -1
 * StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A", 8)  = 7
 * StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 8)  = 5
 * StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB", 8) = 4
 * StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 9)  = 5
 * StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", -1) = -1
 * StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A", 0)  = 0
 * StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 0)  = -1
 * </pre>
 *
 * @param str  the String to check, may be null
 * @param searchStr  the String to find, may be null
 * @param startPos  the start position
 * @return the first index of the search String,
 *  -1 if no match or <code>null</code> string input
 * @since 2.5
 */
public static int lastIndexOfIgnoreCase(String str, String searchStr, int startPos) {
    if (str == null || searchStr == null) {
        return -1;
    }
    if (startPos > (str.length() - searchStr.length())) {
        startPos = str.length() - searchStr.length();
    }
    if (startPos < 0) {
        return -1;
    }
    if (searchStr.length() == 0) {
        return startPos;
    }

    for (int i = startPos; i >= 0; i--) {
        if (str.regionMatches(true, i, searchStr, 0, searchStr.length())) {
            return i;
        }
    }
    return -1;
}