简体   繁体   中英

Excel left and right substring

I have text in a cell which starts with [ and ends in ] and I want to show the text between these two characters.

So far I have this:

    =LEFT(A2, SEARCH("]",A2)-1)

but it still shows as [1234. I just need to figure out how to remove the first [.

There are several ways. If you know your string always starts with [ and ends with ] then you could use:

    =SUBSTITUTE(SUBSTITUTE(A2,"[",""),"]","")

If there may be text before [ and / or after ], then try:

    =MID(A2,FIND("[",A2)+1,FIND("]",A2)-FIND("[",A2)-1)

如果你想“剥离”第一个和最后一个字符,而不管它们是什么,你可以这样做:

=RIGHT(LEFT(RC[-1],LEN(RC[-1])-1),LEN(RC[-1])-2)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM