Raj Raj - 9 months ago 75
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


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?