zoukankan      html  css  js  c++  java
  • Excel lastindex of a substring

    I think I get what you mean. Let's say for example you want the right-most in the following string (which is stored in cell A1):

    Drive:FolderSubFolderFilename.ext

    To get the position of the last \, you would use this formula:

    =FIND("@",SUBSTITUTE(A1,"","@",(LEN(A1)-LEN(SUBSTITUTE(A1,"","")))/LEN("")))
    

    That tells us the right-most is at character 24. It does this by looking for "@" and substituting the very last "" with an "@". It determines the last one by using

    (len(string)-len(substitute(string, substring, "")))len(substring)
    

    In this scenario, the substring is simply "" which has a length of 1, so you could leave off the division at the end and just use:

    =FIND("@",SUBSTITUTE(A1,"","@",LEN(A1)-LEN(SUBSTITUTE(A1,"",""))))
    

    Now we can use that to get the folder path:

    =LEFT(A1,FIND("@",SUBSTITUTE(A1,"","@",LEN(A1)-LEN(SUBSTITUTE(A1,"","")))))
    

    Here's the folder path without the trailing

    =LEFT(A1,FIND("@",SUBSTITUTE(A1,"","@",LEN(A1)-LEN(SUBSTITUTE(A1,"",""))))-1)
    

    And to get just the filename:

    =MID(A1,FIND("@",SUBSTITUTE(A1,"","@",LEN(A1)-LEN(SUBSTITUTE(A1,"",""))))+1,LEN(A1))
    

    However, here is an alternate version of getting everything to the right of the last instance of a specific character. So using our same example, this would also return the file name:

    =TRIM(RIGHT(SUBSTITUTE(A1,"",REPT(" ",LEN(A1))),LEN(A1)))
    
  • 相关阅读:
    tcp 粘包 和 TCP_NODELAY 学习
    分解抓取的包文件代码实现学习
    谨慎使用多线程中的fork 学习!!!!
    面试题
    Java并发编程:Lock
    为什么匿名内部类参数必须为final类型
    sql 面试题
    java hashCode方法返回值
    数组初始化
    Java内存模型
  • 原文地址:https://www.cnblogs.com/emanlee/p/8939110.html
Copyright © 2011-2022 走看看