11

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)

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

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) I use "ç" so that I can later use the "SPLIT" command to split on every "ç".

2

1 Answer 1

14

My way of approaching this would be to use back-references in the third argument:

=REGEXREPLACE(C3,"\s(\d)","ç$1")

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.