import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
public class Main {
public static void main(String[] args) throws Exception {
ConfigurableListableBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(
"context.xml"));
Pattern pattern = (Pattern) beanFactory.getBean("pattern");
Matcher matcher = pattern.matcher("abc abc abc");
int matchCount = 0;
while (matcher.find()) {
matchCount++;
}
System.out.println(matchCount);
}
}
|