String matching with * ( that matches with any ) in any of the two strings | Java program for string matching with * ; Function to check if the two strings can be matched or not ; if the string don 't have *  then character at that position  must be same. ; Driver code
import java . util . * ; public class GfG { public static int doMatch ( String A , String B ) { for ( int i = 0 ; i < A . length ( ) ; i ++ ) { if ( A . charAt ( i ) != ' * ' && B . charAt ( i ) != ' * ' ) { if ( A . charAt ( i ) != B . charAt ( i ) ) return 0 ; } } return 1 ; } public static void main ( String [ ] args ) { String A = " gee * sforgeeks " ; String B = " geeksforgeeks " ; System . out . println ( doMatch ( A , B ) ) ; } }