2017-08-14 34 views
0

在谷歌表,我想替换以下文字:谷歌张REGEXREPLACE()与自身替换文本

The ANS consists of fibers that stimulate ((1smooth muscle)), ((2cardiac muscle)), and ((3glandular cells)).

下面这段文字:

The ANS consists of fibers that stimulate {{c1::smooth muscle}}, {{c2::cardiac muscle}}, and {{c3::glandular cells}}.

我知道我是否使用=REGEXREPLACE(E3, "\(\([0-9]*", "{{c::")我可以在这里:

The ANS consists of fibers that stimulate {{c::smooth muscle)), {{c::cardiac muscle)), and {{c::glandular cells)).

但是我不知道如何保留原始数字

回答

1

Nvm,想通了。

在该术语周围放置括号可以让您在替换字符串中再次引用它。

例如,我对我的问题的解决方案是这样的:

=REGEXREPLACE(E3, "\(\(([0-9]*)", "{{c$1::")

这工作,因为把[0-9]*括号像这样:([0-9]*)允许它作为$1在我替换字符串引用。

我假设,如果在此之后我还有另一个用括号括起来的短语,它将能够被$2引用。

希望这可以帮助未来的人。

1

通行证1:

搜索模式:(((\ d)(+)

代用:{{C $ 1 :: $ 2

通行证2:

搜索模式:))

Replacment:}}

我发挥它周围的一些更多,这是不行的它在一个通:

搜索模式:\(\((\d)(.+?)\b\)\)

替换:{{C$1::$2}}