Search code examples
regexgoogle-sheetsgoogle-sheets-formulaarray-formulas

Google sheets extract the last part of path file


I have this data in Google Sheets cells:

Dom\SKUto\ctures\VN_0001.png
Dom\SKUto\ctures\sinom\VN_0002.JPG
Dom\SKUto\ctures\folder\VN_0003.jpg
pictures\folder\VN_0004.jpg

I want to return in another cell only the last part of it (the picture name and extension)

VN_0001.png
VN_0002.JPG
VN_0003.jpg
VN_0004.jpg

How do I do that in Google Sheets?


Solution

  • Please try the following formula

    =ArrayFormula(REGEXREPLACE(Q2:Q,"(.*\\)(.*)$","$2"))
    

    OR

    =ArrayFormula(IF(Q2:Q="",,(REGEXEXTRACT(Q2:Q,".*\\(.*)$"))))
    

    (adjust ranges to your needs)

    enter image description here