Code example for Matcher

Methods: group, matches

0
 
	private Pattern pattern = Pattern.compile("^\\s*include\\s+(.+)\\s*$");
	 
	public ContentFragment parse(String source) {
		Matcher m = pattern.matcher(source);
		if (m.matches()) {
			return new IncludeFragment(m.group(1));
		} 
		return null; 
	} 
	 
	private static class IncludeFragment implements ContentFragment { 
		 
		private String url;
	 
		public IncludeFragment(String url) {
			this.url = url;
		} 
 
		public int getLength(HttpServletRequest request,
				HttpServletResponse response) {