Skip to main content
Solved

REGEX_REPLACE to replace text in variable

  • April 27, 2021
  • 2 replies
  • 29 views

Forum|alt.badge.img+3

Dear community,

first of all I really appreciate this forum, even if just as a silent participant so far. I’m pulling my hair out trying to replace strings in variables to make them ready for webmerge/formstack documents.

Input string: my webmerge variable
Wanted result: {$my_webmerge_variable}

Formula I am using: REGEX_REPLACE(REGEX_REPLACE({regex test},"\A","{$"), “\s”, “_”)
Result I am getting: {$my_webmerge_variable

How do I get the closing brace = } at the end of the variable? I tried $ and \z but they don’t seem to be working. Thank you all in advance, any help is much appreciated :slightly_smiling_face:

Best answer by ScottWorld

Welcome to the community, @FrankLovesAirtable!

I’m not a REGEX expert, but are you just looking to add brackets & replace the spaces with underscores?

If so, you could just do it simply like this:

"{$" & SUBSTITUTE(Input," ","_") & "}"

2 replies

ScottWorld
Forum|alt.badge.img+35
  • Genius
  • 9770 replies
  • Answer
  • April 27, 2021

Welcome to the community, @FrankLovesAirtable!

I’m not a REGEX expert, but are you just looking to add brackets & replace the spaces with underscores?

If so, you could just do it simply like this:

"{$" & SUBSTITUTE(Input," ","_") & "}"


Forum|alt.badge.img+3
  • Author
  • New Participant
  • 2 replies
  • April 28, 2021

Welcome to the community, @FrankLovesAirtable!

I’m not a REGEX expert, but are you just looking to add brackets & replace the spaces with underscores?

If so, you could just do it simply like this:

"{$" & SUBSTITUTE(Input," ","_") & "}"


Dear @ScottWorld,

you help is very much appreciated and your solution works perfectly well. This function also seems to be more of the standard repertoire from Airtable so to speak, using this one from now one. Tagged as Solution. Thank you.