matcher

A Java regular expression example (featuring Pattern and Matcher classes)

Summary: Java regular expressions in Java 1.4, featuring regex expressions and pattern matching, using the new Java Pattern and Matcher classes.

The following Java example offers an introduction to regular expressions in Java 1.4. In this code we're creating a regular expression that can search for a date. Specifically, that date must be in a format of two digits, followed by a hyphen, followed by two digits, followed by a hyphen, followed by four digits.

This date pattern is created in this line of code:

Java: How to test if a String contains a case-insensitive regex pattern

Java String FAQ: How can I tell if a Java String contains a given regular expression (regex) pattern?

In a Java program, you want to determine whether a String contains a case-insensitive regular expression (regex). You don't want to manipulate the String or extract the match, you just want to determine whether the pattern exists at least one time in the given String.

A Java String regex pattern search example

Problem: In a Java program, you want to determine whether a String contains a certain pattern. The pattern can be a simple String, or a more complicated regular expression (regex).

Java URL example - A Java class to download and parse URL contents

Java URL download FAQ: Can you share some source code for a Java URL example, specifically a Java class to download and parse the contents of a URL?

This example is a little weak, but it's a program that downloads and parses the contents of a given URL. The purpose has nothing to do with URLs ... it has a lot more to do with the parsing that I am trying to achieve. The parsing code is actually going to be used in an anti-spam program that I am working on.