package com.mindprod.example;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.lang.System.*;
/**
* LookingAt with a Regex.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 2008-01-29
* @since 2008-01-29
*/
public class TestRegexLookingAt
{
private static final Pattern pattern = Pattern.compile( "<td>([^<>]++)</td>" );
/**
* main method
*
* @param args not used
*/
public static void main( String[] args )
{
final String lookIn = "<td>orca</td> then some unrelated junk";
final Matcher m = pattern.matcher( lookIn );
if ( m.lookingAt() )
{
final int gc = m.groupCount();
for ( int i = 0; i <= gc; i++ )
{
out.println( i + " : " + m.group( i ) );
}
}
}
}