Skip to main content

Extract numbers from field into a new field

  • October 19, 2023
  • 5 replies
  • 61 views

Forum|alt.badge.img+7

My field has a name followed by a number - SAM ADAMS (1234).   I need to put the 1234 in it's own field.   What is the best way to write a formula to do that?   

5 replies

Databaser
Forum|alt.badge.img+25
  • Brainy
  • October 19, 2023

Try this:

 

MID({field name}, FIND("(", {field name})+1, LEN({field name})-FIND("(", {field name})-1)

 


Forum|alt.badge.img+21
  • Inspiring
  • October 20, 2023

Here is the formula using Regex.

IF( {Name&Number}, REGEX_EXTRACT( {Name&Number}, "\\((\\d*)\\)$" ) )

 


ScottWorld
Forum|alt.badge.img+35
  • Genius
  • October 20, 2023

Actually, I just looked this up — this is the formula you would use to extract numbers from a string of text:

 
IF(
{text},
REGEX_REPLACE({text}, "\\D", "")
)

Forum|alt.badge.img+7
  • Author
  • Inspiring
  • October 26, 2023

Actually, I just looked this up — this is the formula you would use to extract numbers from a string of text:

 
IF(
{text},
REGEX_REPLACE({text}, "\\D", "")
)

Thanks, Scott.  I used an alternative method not the regex function.   


ScottWorld
Forum|alt.badge.img+35
  • Genius
  • October 26, 2023

Another way of doing this could be to use Airtable's VALUE() function, but that is highly unpredictable since it also performs math! So use that one with caution.