<%@ page language="java" contentType="text/html; charset=gb2312" pageEncoding="gb2312"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><
1.简单匹配小案例 public static void main( String[] args ){ // 按指定模式在字符串查找 String line = "This order was placed for QT3000! OK? This is OK."; String pattern = "(OK)\\?"; // 创建 Pattern 对象 Pattern r = Pattern.compile(pattern); // 现在创建 matcher 对象