Here you can find the source of minIndexOfOneOf(String string, int start, String needles)
Parameter | Description |
---|---|
string | String to scan. |
start | Position of first character to take into account. |
needles | Characters to scan for. |
public static int minIndexOfOneOf(String string, int start, String needles)
//package com.java2s; /*/* w w w .j av a2 s .c om*/ * dmfs - http://dmfs.org/ * * Copyright (C) 2012 Marten Gajda <marten@dmfs.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ public class Main { /** * Find the first occurrence of any character in needles in string from the position start on. * * @param string * {@link String} to scan. * * @param start * Position of first character to take into account. * * @param needles * Characters to scan for. * * @return The first occurrence of any element of needles or {@code -1} if none was found. * */ public static int minIndexOfOneOf(String string, int start, String needles) { if (string == null || string.length() == 0) { return -1; } int len = string.length(); while (start < len) { if (needles.indexOf(string.charAt(start)) >= 0) { return start; } ++start; } return -1; } }