js:var m = /(\d{4}-\d{2}-\d{2}\d{2}:\d{2}:\d{2})|(\d{2}-\d{2}\d{2}:\d{2}:\d{2})|(\d{2}:\d{2}:\d{2})/; var s = "2012-01-23 21:08:29"; //s = "01-23 21:08:29"; //s = "21:08:29"; alert(m.test(s)); java:将上面的\d换成\\d