Return Text Before Nth Instance of Particular Character

  • I have a series of functional locations that can go down to seven levels, separated by '-' within the text. I need to extract the text to the fifth level; however, there is not a standard number of characters per level. E.g.


    CT-EJ-844-F-ACP-001-A

    CT-EJ-715-A-SS-004


    The result I would like for each of those is


    CT-EJ-844-F-ACP

    CT-EJ-715-A-SS


    But of course there's a different number of characters in fifth level (and sometimes in the fourth, too), so instead I would like to eliminate text after the fifth "-" but googling isn't helping me find a way to do that.


    TIA for any help!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!