Here you can find the source of startsWithOrMatches(String s1, String s2)
public static boolean startsWithOrMatches(String s1, String s2)
//package com.java2s; public class Main { /**/*from w ww. j a v a2 s . c o m*/ * Combination of startsWith and matches string comparison. StartsWith has the higher priority. Null checking is * also included. If both parameters are null, the returned value is true. */ public static boolean startsWithOrMatches(String s1, String s2) { if (s1 == null) { return s2 == null; } if (s2 == null) { return false; } return s1.startsWith(s2) || s1.matches(s2); } }