Regex to allow text, some special characters and keep below a certain length

I am trying to create a validation expression that checks the length of an input and allows the use of text and punctuation characters (for example,?;:! "£ $%)

What I have come up with so far is this "^\s*(\w\s*){1,2046}\s*$", but it will not give any punctuation. Honestly, I'm pretty sketchy in this area, so any help would be greatly appreciated!

Thanks,

Steve

+3
source share
5 answers
^[\w\s.,:;!?€¥£¢$-]{0,2048}$

^ - /
[] -
\w -
\s - .,:;!?€¥£¢$- -
{} - (, )
$ - /

+7

:

^\s*([\w,\?;:!"£$%]\s*){1,2046}$

, , .

, , :

^(?=.{1,2046}$)\s*([\w,\?;:!"£$%]\s*)+$

( , . + {1,}, .)

+1

, ? ? \ D ,

+1

, , : , . script.

, - . SQL-.

+1

:

^\s*([\w\s\?\;\:\!\"£\$%]{1,2046})\s*$
0

Source: https://habr.com/ru/post/1725815/


All Articles