Skip to main content
Solved

Formula for specific character count in string

  • November 28, 2019
  • 3 replies
  • 158 views

Burner
Forum|alt.badge.img+15

Hi. I’m new to Airtable and trying to find a formula that will count the number of spaces in a string. For example, when this formula is applied to the string “How are you doing?”, I want the formula to return 3. I tried using the FIND function, but all that does is to find the position of the first instance of, say, a space in this example. I’m looking for a formula to count the number of spaces.

Thank you.

Best answer by Justin_Barrett

Compare the length of the original string with the length of a string that’s had all the spaces removed using the SUBSTITUTE() function:

LEN({String Field}) - LEN(SUBSTITUTE({String Field}, " ", ""))

3 replies

Forum|alt.badge.img+4
  • Known Participant
  • November 28, 2019

Hey @Burner,
Check out @W_Vann_Hall’s code at Count multiple keywords in text
Cheers,
Neil


Justin_Barrett
Forum|alt.badge.img+21
  • Inspiring
  • Answer
  • November 29, 2019

Compare the length of the original string with the length of a string that’s had all the spaces removed using the SUBSTITUTE() function:

LEN({String Field}) - LEN(SUBSTITUTE({String Field}, " ", ""))

Burner
Forum|alt.badge.img+15
  • Author
  • Known Participant
  • November 29, 2019

Compare the length of the original string with the length of a string that’s had all the spaces removed using the SUBSTITUTE() function:

LEN({String Field}) - LEN(SUBSTITUTE({String Field}, " ", ""))

Excellent! Just what I needed. Thank you, Justin. :thumbs_up: