Help

How to delete part of a text after and including a hyphen?

Topic Labels: Formulas
262 5
cancel
Showing results for 
Search instead for 
Did you mean: 

If someone could help me with this, I’d be extremely grateful. I can’t figure this out.
This is what I"d like to achieve through a formula:

Screen Shot 2021-08-17 at 5.57.03 PM

Most Track Titles have a name followed by a “space hyphen space” and a suffix.
I’d like to automatically delete everything after and including the “space hyphen space”.
If Track Title is not followed by “space hyphen space”, just copy the Track Title over.

Thank you so much for pointing me in the right direction.

5 Replies 5

I have come this far, but it results in an #ERROR! for TRACK TITLE C:

> IF(
>     {TRACK TITLE},
>     SUBSTITUTE({TRACK TITLE},
>     REGEX_EXTRACT({TRACK TITLE}," -.*"),""
>     ))

Welcome back to the Airtable community!

Regular expressions can be tricky to setup. Try this formula. It looks for a string of characters that are not hyphens and then trims any leading/trailing space.

TRIM(REGEX_EXTRACT({TRACK TITLE}, "[^-]*"))

The problem with this formula is that REGEX_EXTRACT returns an error if the pattern does not have any matches.

Thank you so much, kuovonne.

Would you mind adding your line of code to my formula? When I try to do it, I get formula syntax errors.
Thank you!

My formula does not need to be embedded in your formula. It is a standalone formula.

Labels