[英]sed replacement for a string
(declare-const buabor Real)
which I want to replace as我想替换为
(declare-fun buabor () Real)
can it be done with sed?可以用 sed 完成吗?
I tried我试过了
sed 's/(declare-const\s([a-z])\s(Real))/(declare-fun\s\2\(\)\3/)g'
but was not able to get the result any help would be great但无法得到结果任何帮助都会很棒
This should do (assuming GNU sed
as \s
is used):这应该可以(假设
GNU sed
作为\s
):
sed 's/(declare-const\s\([a-z]*\)/(declare-fun \1()/'
(
and )
will be matched literally in search section.(
和)
将在搜索部分按字面意思匹配。 See also BRE-vs-ERE section in the manual\(
and \)
will then become capture group \(
和\)
然后将成为捕获组[az]*
will match zero or more lowercase alphabets [az]*
将匹配零个或多个小写字母A few more observations:还有一些观察:
(
and )
aren't special in replacement section (
和)
在替换部分并不特殊\s
is again not special in replacement section, will insert s
\s
在替换部分再次不是特殊的,将插入s
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.