Here you can find the source of sliceAndMatch(String fstring, String rstring)
public static String sliceAndMatch(String fstring, String rstring)
//package com.java2s; public class Main { public static String sliceAndMatch(String fstring, String rstring) { String resultString = ""; for (int i = 0; i < fstring.length(); i++) { String subString = fstring.substring(i, fstring.length()); if (rstring.startsWith(subString)) { resultString += subString + rstring.substring(subString.length()); break; }//from w ww .j av a 2s .co m resultString += fstring.charAt(i); } return resultString; } }