Setting a minimum/maximum character count for any character using a regular expression

前端 未结 5 1744
野趣味
野趣味 2021-02-01 12:44

I am trying to write a regular expression that will be used on a text box to validate its contents to see if it is between 1 and 35. The characters within the text box can be an

5条回答
  •  悲哀的现实
    2021-02-01 13:39

    It's usually the metacharacter . when not inside a character class.

    So use ^.{1,35}$. However, dot does not include newlines unless the dot-all modifier is applied against it.

    You can use ^[\S\s]{1,35}$ without any modifiers, and this includes newlines as well.

提交回复
热议问题