if (argv.length < 1) {
System.out.println ("usage: emailaddress ...");
}
// Compile the email address detector pattern
Pattern pattern = Pattern.compile (
"([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]"
+ "{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))"
+ "([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)",
Pattern.MULTILINE);
// Make a Matcher object for the pattern
Matcher matcher = pattern.matcher ("");
// loop through the args and find the addrs in each one
for (int i = 0; i < argv.length; i++) {
boolean matched = false;
System.out.println ("");
System.out.println ("Looking at " + argv [i] + " ...");
// reset the Matcher to look at the current arg string
matcher.reset (argv [i]);
// loop while matches are encountered
while (matcher.find())
{
// found one
System.out.println ("\t" + matcher.group());
matched = true;
}
if ( ! matched) {
System.out.println ("\tNo email addresses found");
}
}