import java.util.regex.Matcher; import java.util.regex.Pattern; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author chunxiao * @version 1.0 * @time 2011-12-12 16:48 */ public class AnaysisUrl { public static void main(String[] args) { String str = "http://localhost/axix2/services/ManagersUser?sss?xx"; Pattern pattern = Pattern.compile("/(\\w*)\\?"); Matcher matcher = pattern.matcher(str); while (matcher.find()) { System.out.println(matcher.group(1)); } } }