与我之前的问题相关,我有一个以下格式的字符串:
this {is} a [sample] string with [some] {special} words. [another one]
Run Code Online (Sandbox Code Playgroud)
在正方形或大括号内提取单词的正则表达式是什么,即.
{is}
[sample]
[some]
{special}
[another one]
Run Code Online (Sandbox Code Playgroud)
注意:在我的用例中,括号不能嵌套.我还想保留封闭的字符,这样我就可以在处理结果时区分它们.
regex ×1