Can anyone tell me how to make regex for square brackets ( [ ] ) in JavaScript?
You need to escape the square brackets with a backslash: \[\]
\[\]