I've got the following text: "1-1/3 cups warm WATER 2 tablespoons white CHIA SEED MEAL 1/4 cup melted HONEY" - I want to replace all spaces followed by a number with "ç" (1)
我有以下文字:“1-1 / 3杯温水2汤匙白色CHIA SEED MEAL 1/4杯融化蜂蜜” - 我想用“ç”替换所有空格后跟一个数字(1)
Usually regex in GSheets uses parenthesis to form capturing groups: when I use =REGEXEXTRACT(B3,"(\s)\d")
I get a single space like I'm supposed to, but if I use
=REGEXREPLACE(B3,"(\s)\d","ç")
I get Ingredients:ç-1/3 cups warm WATERç tablespoons white CHIA SEED MEALç/4 cup melted HONEY
通常GSheets中的正则表达式使用括号来形成捕获组:当我使用= REGEXEXTRACT(B3,“(\ s)\ d”)时,我得到一个像我应该的单个空格,但如果我使用= REGEXREPLACE(B3,“ (\ s)\ d“,”ç“)我得到的成分:ç-1/3杯温暖的WATERç汤匙白色CHIASEEDMEALç/ 4杯融化的蜂蜜
Does anybody know how to get Google to replace only the space, so that I get output like this: Ingredients:ç1-1/3 cups warm WATERç2 tablespoons white CHIA SEED MEALç1/4 cup melted HONEY
? Thanks a ton!
有没有人知道如何让谷歌只更换空间,这样我得到这样的输出:成分:ç1-1/ 3杯温暖WATERç2汤匙白色CHIASEEDMEALç1/ 4杯融化的蜂蜜?万分感谢!
(1) I use "ç" so that I can later use the "SPLIT" command to split on every "ç".
(1)我使用“ç”以便稍后我可以使用“SPLIT”命令拆分每个“ç”。
1 个解决方案
#1
10
My way of approaching this would be to use back-references in the third argument:
我接近这个的方法是在第三个参数中使用反向引用:
=REGEXREPLACE(C3,"\s(\d)","ç$1")
= REGEXREPLACE(C3, “\ S(\ d)”, “C $ 1”)
#1
10
My way of approaching this would be to use back-references in the third argument:
我接近这个的方法是在第三个参数中使用反向引用:
=REGEXREPLACE(C3,"\s(\d)","ç$1")
= REGEXREPLACE(C3, “\ S(\ d)”, “C $ 1”)