Java String Sub String substringFromMatch(String match, String string)

Here you can find the source of substringFromMatch(String match, String string)

Description

substring From Match

License

Open Source License

Return

A substring of given string starting from the first occurrence of given match. Empty string if no match is found.

Declaration

public static String substringFromMatch(String match, String string) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007 Bruno Medeiros and other Contributors.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from ww  w.  j a  va2s.  c  o  m*/
 *     Bruno Medeiros - initial implementation
 *******************************************************************************/

public class Main {
    /** @return A substring of given string starting from the first occurrence of given match. 
     * Empty string if no match is found. */
    public static String substringFromMatch(char match, String string) {
        int indexOf = string.indexOf(match);
        return indexOf == -1 ? "" : string.substring(indexOf);
    }

    /** @return A substring of given string starting from the first occurrence of given match. 
     * Empty string if no match is found. */
    public static String substringFromMatch(String match, String string) {
        int indexOf = string.indexOf(match);
        return indexOf == -1 ? "" : string.substring(indexOf);
    }
}

Related

  1. substringDelimited(String string, String start, String end, int startingPosition)
  2. substringEL(String str, int index, String defaultValue)
  3. substringEnd(String string, int start, int length)
  4. substringEquals(final String s1, final int fromIndex1, final int toIndex1, final String s2, final int fromIndex2, final int toIndex2)
  5. subStringExe(String s, String jmp, String sb, String se)
  6. substringFromMultiValuedFields(int start, int end, String[] fieldValues, int offsetGap, String interFieldJoiner)
  7. substringGuarded(String s, int position, int count)
  8. subStringIgnoreCase(String str, String separator, Integer stratNum, Integer endNum)
  9. substringInBetween(String name, String prefix, String delimiter)