1
我試圖獲取這些日期22-APR-16 11.00.00.000000和22-APR-16 10.30.00.000000。 我的代碼存在,但無法找到,我該怎麼辦?Java查找字符串正則表達式
String pattern = "(Başlangıç Tarihi:\\s+)([0-9/:]+\\s+[0-9:]+)(.*)\\s+(Bitiş Tarihi:\\s+)([0-9/:]+\\s+[0-9:]+)(.*)";
Pattern r = Pattern.compile(pattern);
String text = "Başlangıç Tarihi: 22-APR-16 11.00.00.000000 AM Bitiş Tarihi: 22-APR-16 10.30.00.000000 PM";
Matcher m = r.matcher(text);
if(m.find())
{
String startDate = m.group(2);
String endDate = m.group(5);
System.out.println("Start Date : " + startDate);
System.out.println("End Date : " + endDate);
}
非常感謝你@ rock321987 – little
@little – rock321987