相关疑难解决方法(0)

sed - 如何(不)匹配不匹配的括号

如何仅在关闭括号的行上进行操作?

例如,我想更改“.is”行并添加一个括号,但不添加带有未闭合括号的行。

所以这些被改变了

this_thing.is 24  ->   (this_thing).is 24
that.is 50        ->   (that).is 50
a[23].is == 10    ->     a[23].is == 10
a.is true         ->   (this_thing).is 24
this_thing.is 24  ->   (this_thing).is 24
Run Code Online (Sandbox Code Playgroud)

但这些不是:

this_thing.is (24
((that).is 50
(a[23].is == 10
a.is ( true
(this_thing.is 24
Run Code Online (Sandbox Code Playgroud)

理想情况下也(不是)

a{.is true
this_thing{.is 24
Run Code Online (Sandbox Code Playgroud)

并不是)

a[.is true
this_thing[.is 24 
Run Code Online (Sandbox Code Playgroud)

我有一个带有 /.is/ 的匹配器,但是如何匹配不匹配的括号?

sed regular-expression

5
推荐指数
1
解决办法
2253
查看次数

标签 统计

regular-expression ×1

sed ×1