htmlregex

How to write regular expression with format "[12,23][12,23]"?


I am struggling in this issue.

Target format should be [12,23][12,23] or [234,324][34,324] they all legally. just like [int,int][int,int]

I confused with this regular expression with Symbol [ and ]

BTW, I am using this in HTML5, trying to restrict user input. Thanks in advances!


Solution

  • Use backslash (\) to escape special characters. Here is a test page you may use: https://www.regexpal.com/ The first part of your expression will look like:

    /\[[0-9]{2,3},[0-9]{2,3}\]/