Javascript match() and invalid quantifier
javascript, match, regex
Solution
JavaScript does not support lookbehind assertions: `(?<= Received: )` is not a valid construct. That appears to be the source of your error.
You'll need to integrate the lookbehind into your match:
someString.match(/ Received: ([^;]*)/);
With the `[^;]*`, you don't even need the lookahead any more.
If you need to access the contents of the first capturing group directly, you could try this:
var receivedDateString = / Received: ([^;]*)/.exec(someString)[1]
Note that this assumes that there will be a match (if no `Received:` is found in the string, the indexing operation would fail).
Problem
I have a problem with using this regular expression in javascript: ``` (?<= Received: )(.*?)(?=; ) ``` What I am trying is to match everythig between two strings, in this case between "Received: " and "; ". Here is my code: ``` var someString = "BlaBlaBla Received: blablabla; BlaBlaBla" var receivedString = someString.match(/(?<= Received: )(.*?)(?=; )/); ``` But for the second line, I am getting an error in firebug: ``` Error: invalid quantifier Source Code: var receivedDateString = dates.match(/(?<= Received: )(.*?)(?=; )); ``` Thank you very much for your help.