正则表达式用于括号匹配

I a using the current regex /(?:^|[^\/\\])\[([\w\s-]*)($|\[)/ to match when user starts to enter chars and enter [some tex, to match this. When he closes it stops the match.

The problem is that i added condition in front, the ?: and if he enter \[ or /[, i am not going to match it.

Well but, if he has something like [text][bla - in this i will match the previous ] bracket and the string will be ][bla, but i don't want this. If he enters [test] [car - this will match the space in front and will be _[car - _ is space.

我希望两者都只从开括号匹配,而不是之前。你们有一些想法吗?谢谢!

评论