如此处所示:
http://jsfiddle.net/beardedgrandma/x8fy9/
这个正则表达式:
/([\w .]*)[~]([\w .]*)(\(|Release Date)/
在此文本输入上失败:
<div>Watergate Files: Bernstein & Woodward ~ Alastair Campbell (Author) (19)Release Date: Decemb</div>
据推测,这是因为标题中的标点符号:
Watergate Files: Bernstein & Woodward
如何解决此问题?
答案 0 :(得分:2)
尝试:
/([^~]+)~([^~(]+?)(?:\(|Release Date)/