Raj Raj - 4 years ago 287
Javascript Question

Positive look behind in JavaScript regular expression

I've a document from which I need to extract some data. Document contain strings like these

Text:"How secure is my information?"

I need to extract text which is in double quotes after the literal

How secure is my information?

How do I do this with regex in Javascript

Answer Source

JavaScript regular expressions do not support lookbehinds. You have to use capturing parenthesis instead:

var str = 'Text:"How secure is my information?"',
    reg = /Text:"([^"]+)"/;
// -> How secure is my information?
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download