I'm using the following regular expression in my code to validate option symbols:
^([A-Za-z]{1,5}\d? +\b(?<=^.{6}))[0-9]{6}[CcPp][0-9]{8}$
If you notice, I'm using a negative lookbehind assertion to confirm that the previous match was only 6 characters.
However, JScript Regex apparently doesn't support lookbehinds but it does support lookahead.
So, I thought that if I did something like:
^((?=^.{6})[A-Za-z]{1,5}\d? +\b)[0-9]{6}[CcPp][0-9]{8}$
This would work.
However, it appears to not be constraining it in the same way. In the first example, it was useful to say that "the match behind me is 6 characters long". However, now that it is a lookahead this isn't working because there will be 6 characters matched even if it isn't in that first group.
Some examples of test cases I'm working with:
Should fail:
1GOOG 12E456C12345678
GOOG 12E456C12345678
GE 4 12E456C12345678
GE4 12E456C12345678
Should pass:
GOOG1 123456C12345678
F5 123456C12345678
How can I succesfully convert this lookbehind into a lookahead so that I can use this expression in javascript?