package com.mindprod.example;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* use a regex to see if string starts with a given pattern.
* <p/>
* composed with IntelliJ IDEA
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0, 2008-01-29
*/
public class TestLookingAtWithRegex
{
private static final Pattern p = Pattern.compile( "\\<td>([^\\<>]++)\\</td>" );
/**
* test harness
*
* @param args not used
*/
public static void main( String[] args )
{
final String lookIn = "<td>orca</td> then some unrelated junk";
final Matcher m = p.matcher( lookIn );
if ( m.lookingAt() )
{
final int gc = m.groupCount();
for ( int i = 0; i <= gc; i++ )
{
System.out.println( i + " : " + m.group( i ) );
}
}
}
}