Java regex for definite or any character less than 11 -


i rails developer need regular expression can allow shortcode or set of characters not more 11 in total. thinking like:

(7575|[0-9a-za-z& ]*{11}) 

however, has not worked.

i don't know function using (this matters because find , matches behave differently), make things unambiguous, can use following:

^(7575|[0-9a-za-z& ]{1,11})$ 

the above means either match 7575 or match between 1 11 characters character set 0-9a-za-z& . if want allow empty string well, have use {0,11} instead.

a more memory efficient 1 ^(?:7575|[0-9a-za-z& ]{1,11})$ (since there no capture groups).

^ matches beginning of string , $ matches end of string, ensuring there no more characters before or after matched part.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -