Created
August 25, 2015 21:46
-
-
Save kevinmichaelchen/115418325dc8c2f6c45e to your computer and use it in GitHub Desktop.
Pattern Matching in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test { | |
public static void main(String[] args) { | |
Pattern pattern = Pattern.compile( "filename\\*\\d+" ); | |
System.out.println( pattern.matcher( "filename1" ).find() ); // false | |
System.out.println( pattern.matcher( "filename*1" ).find() ); // true | |
System.out.println( pattern.matcher( "filename*12" ).find() ); // true | |
System.out.println( pattern.matcher( "filename**12" ).find() ); // false | |
System.out.println( pattern.matcher( "filenamme*12" ).find() ); // false | |
System.out.println( pattern.matcher( " filename**12 =" ).find() ); // false | |
System.out.println( pattern.matcher( " filename**12=" ).find() ); // false | |
System.out.println( pattern.matcher( "filename*0=\"=?utf-8?B?Tmlt" ).find() ); // true | |
System.out.println( Pattern.compile( "filename\\*0" ).matcher( "filename*0=\"" ).find() ); // true | |
System.out.println( Pattern.compile( "filename\\*0" ).matcher( "filename*1=\"" ).find() ); // false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment