DEV Community

loading...

Discussion on: Regex 101

Collapse
abhishe01794149 profile image
Abhishek Chandel

/([a-zA-Z]{1,5})/g.test('abhishek')

why is this giving true?

Collapse
shreyazz profile image
Shreyas Pahune Author

It is coming true cuz, it is only testing abhis because of the {1,5} clause, and that substring exists in your name abhishek.

Collapse
abhishe01794149 profile image
Abhishek Chandel

then this should give false - /([a-zA-Z]{1,5})/g.test('1abhishek'), but it is giving true again

Thread Thread
shreyazz profile image
Shreyas Pahune Author

Lemme try this on my end