I want to allow []
these brackets in a name field using regex. Please help me on this.
Asked
Active
Viewed 2,082 times
-5

Wiktor Stribiżew
- 607,720
- 39
- 448
- 563

Suraj Chougule
- 35
- 7
-
Just do not restrict the input at all. – Wiktor Stribiżew Jun 14 '16 at 07:01
-
but i also want to retrict user from entering characters such as #,*,&,$ etc. – Suraj Chougule Jun 14 '16 at 07:04
-
i am facing a problem with these brackets only.... – Suraj Chougule Jun 14 '16 at 07:05
-
Where is the problem? Where is the regex you are using? How is it used (what language, method, etc?) Check the [MCVE (minimal complete verifiable example)](http://stackoverflow.com/help/mcve). – Wiktor Stribiżew Jun 14 '16 at 07:06
-
`/^([a-zA-Z '.`"\\:;_(){}<>-]*)?(s\/o|S\/O|w\/o|W\/O|d\/o|D\/O)?([a-zA-Z '.`"\\:;_(){}<>-]*)$/i` this is the regex i am using.. – Suraj Chougule Jun 14 '16 at 07:12
1 Answers
3
Just escape them using \
:
\[
\]

Krzysztof Krasoń
- 26,515
- 16
- 89
- 115
-
-
@SurajChougule If you found it useful consider http://meta.stackexchange.com/questions/173399/how-to-upvote-on-stack-overflow – Krzysztof Krasoń Jun 24 '16 at 11:25