1 package org.seasar.cubby.controller; 2 3 import java.util.regex.Matcher; 4 import java.util.regex.Pattern; 5 6 import junit.framework.TestCase; 7 8 public class RegexTest extends TestCase{ 9 10 public void testConvertUri() throws Exception { 11 Pattern pattern = Pattern.compile("([/]([a-z]+)[/]todo[/]([0-9]+))"); 12 Matcher m = pattern.matcher("/agata/todo/100"); 13 String result = m.replaceAll("/todo/show?id=$3&name=$2"); 14 assertEquals("/todo/show?id=100&name=agata", result); 15 } 16 17 }