klorenz / atom-regex-railroad-diagrams

display regex as railroad diagram, if cursor moves to it
MIT License
250 stars 31 forks source link

Captures in captures #64

Closed BlaM closed 8 years ago

BlaM commented 8 years ago

According to atom-regex-railroad-diagrams this regexp has these three captures:

/^\/((deu|fra|nel)\/(de|en|fr|nl))\//i

capture 1 is "(deu|fra|nel)" capture 2 is "(de|en|fr|nl)" capture 3 is "((deu|fra|nel)\/(de|en|fr|nl))"

However when I run this regexp in JavaScript...

('/deu/de/bauernmarkt').match(/^\/((deu|fra|nel)\/(de|en|fr|nl))\//i);
> ["/deu/de/", "deu/de", "deu", "de"]

the real capture 1 is the one called capture 3 above the real capture 2 is the one called capture 1 above the real capture 3 is the one called capture 2 above

klorenz commented 8 years ago

yes, you are right, I am not sure, if this is easy to fix, I will check these days.