У меня есть регулярное выражение /^\[(text:\s*.+?\s*)\]/mi
, которое в настоящее время работает при захвате текста в скобках, начинающихся с text:
. Вот пример, где он работает:
[text: here is my text that is
captured within the brackets.]
Теперь я хотел бы добавить исключение, чтобы оно допускало определенные скобки, как в следующем случае:
[text: here is my text that is
captured within the brackets
and also include ]
В принципе, мне нужно это, чтобы скобки 
совпадали.
Любая помощь будет принята с благодарностью. Спасибо.
Update:
Вот некоторые случаи, когда текст внутри скобок должен быть сопоставлен:
[text: here is my text that is
captured within the brackets
and also include ]
[text: here is my text that is
captured within the brackets
and also include  and some more text]
[text: ]
![text: cat]
Вот некоторые случаи, когда он не должен совпадать:
[text: here is my text that is
captured within the brackets
and also include ]
[text: here is my text that is
captured within the brackets
and also include ![] (/some/path)]
[text: here is my text that is
captured within the brackets
and also include ! [](/some/path)]
[text: here is my text that is
captured within the brackets
and also include ! [] (/some/path)]