0

Maybe I'm just misunderstanding javascript regular expression, but here's my case:

I have two RegExp objects..

var firstRegEx = RegExp('\/departments\?.*') to match urls such as '/departments?filterby=name&keyword=&paginate=false'

and

var secondRegEx = RegExp('\/department\/([0-9])+\/teams\?.*') to match urls such as '/department/1/teams?filterby=name&keyword=asd&paginate=false'

I've tested these regular expressions in regexr.com it works pretty much as expected, but upon running these into the browser directly, when I try to test firstRegEx with the second string it also returns true.

this firstRegEx.test('/departments/1/teams?filterby=name&keyword=asd&paginate=false') unexpectedly returns true

I don't know if I'm missing something, but what am I doing wrong ??

I'm running under firefox 37.0.1 and chromium Version 41.0.2272.76 Ubuntu 14.04 (64-bit)

cj cabero
  • 383
  • 10
  • 23

0 Answers0