How to detect exact length in regex

前端 未结 8 566
青春惊慌失措
青春惊慌失措 2020-12-11 02:42

I have two regular expressions that validate the values entered.

One that allows any length of Alpha-Numeric value:

@\"^\\s*(?[A-Z0-9]+)         


        
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 03:04

    If it's single line, you could specify that your match must happen at the end of the line, like this in .net ...

    ^\s*([0-9]{10})\z
    

    That will accept 1234567890 but reject 12345678901.

提交回复
热议问题