小编knk*_*knk的帖子

提取包含括号的文本

我有一些这样的文字:

Sentence #1 (n tokens):
Blah Blah Blah
[...
 ...
 ...]
( #start first set here
 ... (other possible parens and text here)
 ) #end first set here

(...)
(...)

Sentence #2 (n tokens):
Run Code Online (Sandbox Code Playgroud)

我想提取第二组括号(包括中间的所有内容),即,

(
 ... (other possible parens here)
)
Run Code Online (Sandbox Code Playgroud)

有没有一种 bash 方法来做到这一点。我尝试了简单的

 's/(\(.*\))/\1/'
Run Code Online (Sandbox Code Playgroud)

sed shell-script text-processing

3
推荐指数
1
解决办法
140
查看次数

标签 统计

sed ×1

shell-script ×1

text-processing ×1