Hi @Scott_Callery
I think this Regex will help: REGEX_EXTRACT(Field name, "^\\D*")
Thanks to @Justin_Barrett and his intro to Regex
Hi @Scott_Callery
I think this Regex will help: REGEX_EXTRACT(Field name, "^\\D*")
Thanks to @Justin_Barrett and his intro to Regex
Superb this does exactly what I need :partying_face:
Would you be able to explain what the "^\\D*"
part does?
I looked at the Airtable formula page but it doesn’t give much explanation.
Thanks @Justin_Barrett
Superb this does exactly what I need :partying_face:
Would you be able to explain what the "^\\D*"
part does?
I looked at the Airtable formula page but it doesn’t give much explanation.
Thanks @Justin_Barrett
Hey there!
Regex is a scary monster even for those who work with it all day. It’s essentially a small coding language in and of itself used commonly within JavaScript to Match or manipulate strings of text.
Just a little regex knowledge can go a long way though! It’s definitely worth dipping your toes into
Superb this does exactly what I need :partying_face:
Would you be able to explain what the "^\\D*"
part does?
I looked at the Airtable formula page but it doesn’t give much explanation.
Thanks @Justin_Barrett
The caret (^) at the start tells the interpreter to only look for matches at the start of the string. The token \D
matches any non-digit character, and the asterisk says to match the previous token zero or more times. In short, it matches all non-digit characters at the start of the string. Once a digit is found, the match stops.
FWIW the extra backslash before \D
is required because the backslash in formula strings is an escape character. To ensure that the backslash before the D is maintained as part of that token, you need two backslashes, essentially escaping the escape character itself.
I recommend playing around on regex101.com if you want to learn more about Regex in a hands-on way. It’s not the only site where you can do this, but it’s my favorite so far. Just make sure that you set the “Flavor” option (upper left) to “Golang,” which is the closest Regex variant to what Airtable uses.
The caret (^) at the start tells the interpreter to only look for matches at the start of the string. The token \D
matches any non-digit character, and the asterisk says to match the previous token zero or more times. In short, it matches all non-digit characters at the start of the string. Once a digit is found, the match stops.
FWIW the extra backslash before \D
is required because the backslash in formula strings is an escape character. To ensure that the backslash before the D is maintained as part of that token, you need two backslashes, essentially escaping the escape character itself.
I recommend playing around on regex101.com if you want to learn more about Regex in a hands-on way. It’s not the only site where you can do this, but it’s my favorite so far. Just make sure that you set the “Flavor” option (upper left) to “Golang,” which is the closest Regex variant to what Airtable uses.
This one can be useful too: Introduction to Regular Expressions by Codecademy