How do I return everything to the left of the second to last occurrence of a character? In this case, the character is "-" For example:
- "hello-baby-123-sun" I need to return "hello-baby"
- "hello-baby-123-sun-shine-123", I need to return "hello-baby-123-sun"
Thanks!
I haven't been able to figure it out.
Try using
TEXTBEFORE()function with the instance being-2Alternatively, adding an error control is necessary:
For Older Versions, one can try one of the followings:
• Using
LEFT()&FIND()• Or Using
FILTERXML()╪ as mentioned in comments by @Harun24hr:╪ Note:
FILTERXML()is available fromExcel 2013+onwards as well as it is not applicable inExcel For The WebandExcel For MAC.TEXTBEFORE()works withMS365Exclusively.One can learn more on
FILTERXML()from the following link, nice article by JvdV Sir, Extract substring(s) from string using FILTERXML