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

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:

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.

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

> IF(
>     {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.


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

1 Like

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.

I just tried it. Works beautifully. Thank you so much!!

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.