Here you can find the source of substringUntilMatch(String string, String match)
public static String substringUntilMatch(String string, String match)
//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 w ww .j ava2 s . co m * Bruno Medeiros - initial implementation *******************************************************************************/ public class Main { /** @return a substring of given string up until the start of the first occurrence of given match, * or the whole string if no match is found. */ public static String substringUntilMatch(String string, String match) { int index = string.indexOf(match); return (index == -1) ? string : string.substring(0, index); } }