小编adz*_*adz的帖子

如何提取方括号之间的字符串

我必须使用 Powershell 或 Groovy 脚本从方括号中提取字符串。

电源外壳 :

$string = "[test][OB-110] this is some text"  

$found = $string -match '(?<=\[)[^]]+(?=\])'  
echo $matches
Run Code Online (Sandbox Code Playgroud)

当我运行上面的代码时,它返回:

test 
Run Code Online (Sandbox Code Playgroud)

我希望它返回这个:

test
OB-110
Run Code Online (Sandbox Code Playgroud)

我需要提取括号内的所有文本。

regex powershell groovy

-1
推荐指数
1
解决办法
644
查看次数

标签 统计

groovy ×1

powershell ×1

regex ×1