日期:2014-05-17  浏览次数:20722 次

java 正则表达式
现有一段字符串,如下:
rad_recv: Access-Request packet from host 218.109.255.17:54849, id=4, length=153        Framed-Protocol = PPP   Attr-89 = 0x00  Acct-Session-Id = \"90441101\"        Tue Apr  8 23:30:06 2014 : Debug: Cleaning up request 64708174 ID 53 with timestamp 534415f4 ERX-Dhcp-Mac-Addr = \"8c21.0a1e.44d3\"   Tue Apr  8 23:30:06 2014 : Debug: Waking up in 1 seconds... NAS-Identifier = \"TONGXIANG-01-BRAS-01\" ";


字符串中有一串时间,“Tue Apr  8 23:30:06 2014”,出现的规则不定,也有可能是“Wed Apr  9 23:30:06 2014”,或者“Thr  Apr  10 23:30:06 2014”,我想用java 正则表达式截取出来,怎么截取?

我想通过以Tue或者Wed或者Thr开头的,以2014结尾的规则截取,但是不成功,哪位高手帮忙一下?
------解决方案--------------------
	String s1="rad_recv: Access-Request packet from host 218.109.255.17:54849, id=4, length=153        Framed-Protocol = PPP   Attr-89 = 0x00  Acct-Session-Id = \"90441101\"        Tue Apr  8 23:30:06 2014 : Debug: Cleaning up request 64708174 ID 53 with timestamp 534415f4 ERX-Dhcp-Mac-Addr = \"8c21.0a1e.44d3\"   Tue Apr  8 23:30:06 2014 : Debug: Waking up in 1 seconds... NAS-Identifier = \"TONGXIANG-01-BRAS-01\" ";
  System.out.println(s1.replaceAll(".*(Tue Apr.*?2014).*", "$1"));

------解决方案--------------------
System.out.println(s1.replaceAll(".*((Tue
------解决方案--------------------
Wed
------解决方案--------------------
Thr).*?2014).*", "$1"));