RegEx Starts with [ and ending with ]

前端 未结 4 1802
广开言路
广开言路 2020-12-10 02:43

What is the Regular Expression to find the strings starting with [ and ending with ]. Between [ and] all kind of character are fine.

4条回答
  •  萌比男神i
    2020-12-10 03:15

    You need to use escape character \ for brackets.
    Use .+ if you like to have at least 1 character between the brackets or .* if you accept this string: [].

    ^\[.*\]$
    

提交回复
热议问题