MatchesTest.java


Dosyayı İndir
import java.util.regex.*;

public class MatchesTest {
    
    public static void testMatchesShort(){
        String regex=".*Godoro.*";
        String input="Java Deeply by Godoro Publications";
        boolean  result=Pattern.matches(regex, input);
        System.out.println("Matches : "+result);  
    }
    public static void testMatchesLong(){
        String regex=".*Godoro.*";
        Pattern pattern=Pattern.compile(regex);
        String input="Java Deeply by Godoro Publications";
        Matcher matcher=pattern.matcher(input);
        boolean result=matcher.matches();
        System.out.println("Matches : "+result);  
    }
      public static void testMatchesFlags(){
        String regex=".*godoro.*";
        Pattern pattern=Pattern.compile(regex,Pattern.CASE_INSENSITIVE);
        String input="Java Deeply by Godoro Publications";
        Matcher matcher=pattern.matcher(input);
        boolean result=matcher.matches();
        System.out.println("Matches : "+result);  
    }
    public static void testBeginsMatches(){
        String regex="^Java.*";
        String input="Java Deeply by Godoro Publications";
        boolean  result=Pattern.matches(regex, input);
        System.out.println("Matches : "+result);  
    }
    public static void testEndsMatches(){
        String regex=".*Publications$";
        String input="Java Deeply by Godoro Publications";
        boolean  result=Pattern.matches(regex, input);
        System.out.println("Matches : "+result);  
    }
    public static void main(String[] args) {
        testMatchesFlags();
        
        
    }
}

				
Dosyayı İndir

Bu Sayfayı Paylaş:




Bu Sayfayı Paylaş:

İletişim Bilgileri

Takip Et

Her Hakkı Saklıdır. Bu sitede yayınlanan tüm bilgi ve fikirlerin kullanımından fibiler.com sorumlu değildir. Bu sitede üretilmiş , derlenmiş içerikleri, fibiler.com'u kaynak göstermek koşuluyla kendi sitenizde kullanılabilirsiniz. Ancak telif hakkı olan içeriklerin hakları sahiplerine aittir