I try copy text before last /
Sample:
Result:
I try somelike this but no work in my excel. Return error invalid formula.
=IF(ISERROR(FIND(" ",A2,FIND(" ",A2,1)+1)),A2,LEFT(A2,FIND(" ",A2,FIND(" ",A2,1)+1)))
Not a clear answer, but you may go this way (I used cell A1 for my example):
= LEN(A1)-LEN(SUBSTITUTE(A1;"/";"")
- This will count how many /
you have in A1 cell = SUBSTITUTE(A1;"/";"#";LEN(A1)-LEN(SUBSTITUTE(A1;"/";"")))
/
occurrence with some other unique symbol - #
in my example=FIND("#"; SUBSTITUTE(A1;"/";"#";LEN(A1)-LEN(SUBSTITUTE(A1;"/";""))); 1)
#
, ie location of last /
in initial string.=LEFT(A1; FIND("#"; SUBSTITUTE(A1;"/";"#";LEN(A1)-LEN(SUBSTITUTE(A1;"/";""))); 1)-1)
You could use multiple ways, for example:
MATCH()
the last occurence of the forward slash:
=LEFT(A1,MATCH(2,1/(MID(A1,SEQUENCE(LEN(A1)),1)="/"))-1)
Or if one does not have Microsoft365:
=LEFT(A1,MATCH(2,1/(MID(A1,ROW(A1:INDEX(A:A,LEN(A1))),1)="/"))-1)
SUBSTITUTE()
the last occurence of the forward slash:
=LEFT(A1,FIND("|",SUBSTITUTE(A1,"/","|",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))))-1)
TEXTJOIN()
any other than last part:
=TEXTJOIN("/",,FILTERXML("<t><s>"&SUBSTITUTE(A1,"/","</s><s>")&"</s></t>","//s[position()<last()]"))
Edit:
If this is done in GS for now, you can use REGEXEXTRACT()
inside and INDEX()
:
=INDEX(IF(A2:A="",,REGEXEXTRACT(A2:A,"(^.*)\/")),,)
This will spill all your answers down in the same column.
Just throwing in another version of SUBSTITUTE|RIGHT
in the ring as others have already demonstrated.
=SUBSTITUTE(A2,"/"&TRIM(RIGHT(SUBSTITUTE(A2,"/",REPT(" ",99)),99)),"")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.