Find and Replace "spaces" Script

Hi I have a price field that I auto import prices from and it comes out as “7 99” because that’s how this specific website shows the price. I want to use the find and replace script to replace the spaces " " with a period “.” however that doesn’t work. Idk code but should this fix be done in my data scraping or can airtable fix it.

This can be done with a formula:

SUBSTITUTE({Price Field}, " ", ".")

If you want to turn that into an actual decimal number, wrap that in the VALUE() function:

VALUE(SUBSTITUTE({Price Field}, " ", "."))

Be sure to set the field formatting to display decimal values.

3 Likes

Because you mentioned scraping

Here is another Formula that might come in handy:

REGEX_REPLACE(TRIM({example of scraped text}), '\\s','.')

So this does two important things:

  1. It trims or removes the whitespace that might be dragged along from the scraping process (very common in my experience)
  2. uses the \s regex:
    \s matches any whitespace character (equivalent to [\r \n \t \f \v])
3 Likes