I want to split a line with the following patterns:
date
, time
- name
: message
A message may contain commas, dashes or colons. How can I split them?
Example:
03/05/2014, 16:24 - Steven: Thanks, keep you posted :D
Results:
grp[0]: 03/05/2014<br/>
grp[1]: 16:24<br/>
grp[2]: Steven<br/>
grp[3]: Thanks, keep you posted :D
Update:
The answer provided by Andrew Morton and Alexey Lebedev works:
/(.{10}), (.{5}) - (.*?): (.*)/
尝试模式
(\d{2}\/\d{2}\/\d{4})\s*,\s*(\d{2}:\d{2})\s*-\s*(.*?):\s*(.*)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.