Text formula with regex to format genre names correctly

I have a simple book database and an object for Genres. It has a connection to itself so subgenres can have a parent reference. Each genre has a name:

Fiction
Science Fiction
Historical
Non-Fiction
Biography

They’re hierarchical such that “Fiction” is a genre but so is “Historical” but “Historical” is a subgenre of “Fiction”.

My object has a text formula field I’m calling “Full name” which would be something like this:

{Name} - {Genre Subgenre.Name}

Which would yield:

Fiction –
Fiction – Science Fiction
Fiction – Historical
Non-Fiction –
Non-Fiction – Biography

I’m just trying to show the heirarchy to the user and the “–” is my split it up.

So:

  1. is there a way to optionally print the “–” ?
  2. if not, is there a way to send the entire thing ({Name} - {Genre Subgenre.Name}) thru a regex and remove the empty “–” when showing one of the top-level genres? To be clear what I desire is this:

Fiction
Fiction – Science Fiction
Fiction – Historical
Non-Fiction
Non-Fiction – Biography

Note the lack of “–” after Fiction and Non-Fiction.

Thanks!