Remove everything to the right of a character

Hi, I've searched the forum, but can't seem to find a solution.


I have a series of domain names all different length. Some of them have subdomains, some don't. I need to automatically remove the subdomain text.


Examples:

Domain 1: thisisadomain.com/ = no issue

Domain 2: thisisanewdomain.com/en = I want to remove everything to the right of the /

Domain 3: thisisanotherdomain.com/products/en = I want to remove everything to the right of the first /


I should just end up with:

thisisadomain1.com/

thisisanewdomain.com/

thisisanotherdomain.com/


The issue is the different lengths of the domains before the / appears.


I have it in my head that I should use FIND to find the first / and then replace anything after that with "", but I don't know if that's the right way of thinking - if it is, I can't get it to work! Any help greatly appreciated.


Matt

Best Answer

  • Mike Raposo
    Mike Raposo ✭✭✭✭
    Answer ✓

    Hi Matt,


    You are correct the FIND() function is a part of it, the other function you'll need to use is LEFT() since you're looking to return all of the text to the left of the first / in the domains. This formula should work for what you're looking to do:

    =LEFT([Column Name]@row, FIND("/", [Column Name]@row))

    Hope this helps! Let me know if you have any questions.

    Best,

    Mike

Answers

  • Mike Raposo
    Mike Raposo ✭✭✭✭
    Answer ✓

    Hi Matt,


    You are correct the FIND() function is a part of it, the other function you'll need to use is LEFT() since you're looking to return all of the text to the left of the first / in the domains. This formula should work for what you're looking to do:

    =LEFT([Column Name]@row, FIND("/", [Column Name]@row))

    Hope this helps! Let me know if you have any questions.

    Best,

    Mike

  • Perfect Mike, worked first time, thanks!

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!