question: public static String merge ( String s1 , String s2 ) { if ( X . isEmpty ( s1 ) || X . isEmpty ( s2 ) ) { return ".*" ; } int l1 = s1 . length ( ) ; int l2 = s2 . length ( ) ; if ( l1 > l2 ) { return merge ( s2 , s1 ) ; } int j = 0 ; StringBuilder sb = new StringBuilder ( ) ; boolean all = false ; for ( int i = 0 ; i < l1 && j < l2 ; ) { if ( s1 . charAt ( i ) == s2 . charAt ( j ) ) { sb . append ( s1 . charAt ( i ) ) ; i ++ ; j ++ ; all = false ; } else { if ( ! all ) { sb . append ( ".*" ) ; all = true ; } if ( s1 . charAt ( i ) == '.' && s1 . charAt ( i + 1 ) == '*' ) { i += 2 ; } if ( s2 . charAt ( j ) == '.' && s2 . charAt ( j + 1 ) == '*' ) { j += 2 ; } String c1 = _getmaxstr ( s1 . substring ( i ) , s2 . substring ( j ) ) ; if ( c1 == null ) { i ++ ; continue ; } if ( i + 2 < l1 ) { String c2 = _getmaxstr ( s1 . substring ( i + 1 ) , s2 . substring ( j ) ) ; if ( c2 == null || c1 . length ( ) >= c2 . length ( ) ) { sb . append ( c1 ) ; all = false ; j = c1 . length ( ) + s2 . indexOf ( c1 , j ) ; continue ; } else if ( c2 != null ) { i ++ ; } } else { sb . append ( c1 ) ; all = false ; j = c1 . length ( ) + s2 . indexOf ( c1 , j ) ; break ; } } } if ( ( ! all ) && j < l2 ) { sb . append ( ".*" ) ; } return sb . toString ( ) ; }
target:  merge two string to as a pattern string.