Link to home
Start Free TrialLog in
Avatar of awaters8
awaters8

asked on

Javascript RegEx failing....

i am using a regex in Javascript and keep getting an error.  I have used the same regex on several tester sites andthe parse works fine.  I can't figure out hwy it isn't working my implementation.

Here is the code snippet:

      var re = /^((?<!P\.?\s?O\.?\sBox).)+(?<!P\.?\s?O\.?\sBox)$/i;
      alert("??"+re.Exec(document.registerform.b_address.value));

It doesn't get to the alert before Firefox throws this error:

Error: invalid quantifier ?<!P\.?\s?O\.?\sBox).)+(?<!P\.?\s?O\.?\sBox)$
Source File: ...
Source Code:
      var re = /^((?<!P\.?\s?O\.?\sBox).)+(?<!P\.?\s?O\.?\sBox)$/i;

Thoughts?
ASKER CERTIFIED SOLUTION
Avatar of ddrudik
ddrudik
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of awaters8
awaters8

ASKER

Bummer...Is there a way to accomplish a negative look back in JS?
Thanks for the quick response!
Thanks for the question and the points.
Doesn't /^((?!P\.?\s?O\.?\sBox).)+$/i do he same thing?
It does...I'll report back if any of my test cases fail.