Regex string match -
i attempting create regex satisfies following conditions:
object name must:
- be upper case
- can contain numbers either side of characters
- following characters excluded anywhere '"*'&<>/
any tips on how achieve appreciated.
valid examples:
- site 10
- a23 - flats 12b range , allowance pitch.
- 2 - 9 guardspace avenue.
invalid examples:
- site 10
- a23 / flats 12b range , allowance pitch
- 2 & 9 guardspace avenue
it can achieved following regex:
^[^a-z'"*&<>\/]+$
see demo
it allows letter not '"*'&<>\/
, , requires there no lowercase english letter.
^
- start of string[^a-z'"*&<>\/]+
- 1 or more characters other'
,"
,*
,&
,<
,>
,/
or lowercase english character.$
- end of string
restricting length can achieved limiting quantifier:
^[^a-z'"*&<>\/]{3,60}$
Comments
Post a Comment