I have some strings.
- [ABC]
- [ABC][DEF]
- [ABC][def][GH][I] and etc.
and there are rules.
- Do not nested.
- [ABC] : OK
- [A[BC]] : NO
- Not allowed any character between each brackets. (includes white spaces)
- [ABC][DE] : OK
- [AB] [C] : NO
- [AB]c[DEF] : NO
- String must start with "[" and end with "]"
- Bracket content can have word and number only. not empty or blank.
Here is my works. But it seems not good.
^\[\w.*(\w\]\[\w).*\w\]$
https://regex101.com/r/EQzulB/1
How do I check if this string is valid or invalid?