inetbug
inetbug

Reputation: 409

Calculate the maximum number of characters in the regex

For example, we have the following regex:

/^[a-z]{1,10}-[0-9]{10}$/

This regex allows us to enter a maximum of 21 characters.

Is there an easy way to get number of maximum allowed characters in JavaScript?

Upvotes: 3

Views: 135

Answers (1)

gtournie
gtournie

Reputation: 4382

No, you can't.

If you use "?" or "+" or "*" you can't guess how many characters will match.

Upvotes: 2

Related Questions