Pierce Reed
Pierce Reed

Reputation: 235

Why does this regex fail on the last text input containing punctuation characters?

As demonstrated here:

http://jsfiddle.net/beardedgrandma/x8fy9/

this regex:

/([\w .]*)[~]([\w .]*)(\(|Release Date)/

fails on this text input:

<div>Watergate Files: Bernstein & Woodward ~ Alastair Campbell (Author) (19)Release Date: Decemb</div>

Presumably this is because of the punctuation in the title:

Watergate Files: Bernstein & Woodward

How to correct this?

Upvotes: 1

Views: 72

Answers (1)

Qtax
Qtax

Reputation: 33918

Try:

/([^~]+)~([^~(]+?)(?:\(|Release Date)/

Upvotes: 2

Related Questions