import java.util.regex.Matcher;
import java.util.regex.Pattern;
...

// Note, you get your Patterns with the static factory Pattern.compile
// not with new Pattern.

// simple ? wildcard: match ?gloss.html
Pattern p = Pattern.compile( ".gloss\\.html" );

// simple * wildcard: match g*.txt
Pattern p = Pattern.compile( "g.*\\.txt" );

// match cat.html or dog.html
Pattern p = Pattern.compile( "(cat|dog)\\.html" );

// negative wildcards: match *.html but not cat.html or dog.html
Pattern p = Pattern.compile( "(?!cat\\.html$|dog\\.html$).*\\.html" );

// match email address of the form roedy.green_9@some-place.mind-prod.com
// allow dots anywhere, but not at start of domain name, no + // lets two dots in row pass, and name to start with dot.
Pattern p = Pattern.compile( "[a-z0-9\\-_\\.]++@[a-z0-9\\-]++(\\.[a-z0-9\\-]++)++" );

// dealing with \ and . Match "r*\*.*". On command line would be "r.*\\.*\..*"
Pattern p = Pattern.compile( "r.*\\\\.*\\..*" );

// Using Regex Capture Groups
// search for strings of the form ...<title>...</title>...
// and capture the string between the two tags.
Pattern titleFinder = Pattern.compile( ".*\\<title>([a-zA-Z0-9 ]*)\\</title>.*" );

Matcher m = titleFinder.matcher( "some stuff <title>Exploring Kenya</title> more stuff" );

// prints matches? true
out.println( "matches? " + m.matches() );

// prints count: 1
out.println( "count: " + m.groupCount() );

// prints whole: some stuff <title>Exploring Kenya</title> more stuff
out.println( "whole: " + m.group( 0 ));

// prints captured title: Exploring Kenya
out.println( "captured title: " + m.group( 1 ));

// does my candidate string have this form "<!-- generated -->" with zero or more blanks, tabs, nls etc allowed? */
private static final Pattern startGenerated = Pattern.compile( "\\<\\!\\-\\-\\s*generated\\s*\\-\\-\\>" );
...
if ( startGenerated.matcher( candidate ).matches() )
   {
   out.println( "fits the pattern" );
   }