[英]Finding a character inside a string in Excel
I want to remove all the characters from a string expect whatever character is between a certain set of characters. 我希望删除字符串中的所有字符,期望某些字符集之间的任何字符。 So for example I have the input of Grade:2/2014-2015 and I want the output of just the grade, 2. 所以例如我有Grade:2 / 2014-2015的输入,我想要等级2的输出。
I'm thinking that I need to use the FIND function to grab whatever is between the : and the / , this also needs to work with double characters such 10 however I believe that it would work so long as the defining values with the FIND function are correct. 我想我需要使用FIND函数来抓取:和/之间的任何东西,这也需要使用双字符这样的10但是我相信它只要使用FIND函数定义值就可以工作是正确的。
Unfortunately I am totally lost on this when using the FIND function however if there is another function that would work better I could probably figure it out myself if I knew what function. 不幸的是,当我使用FIND函数时,我完全失去了这个功能,但是如果有另一个功能更好的话我可以自己解决,如果我知道什么功能。
It's not particularly elegant but =MID(A1,FIND(":",A1)+1,FIND("/",A1) - FIND(":",A1) - 1)
would work. 它不是特别优雅但是=MID(A1,FIND(":",A1)+1,FIND("/",A1) - FIND(":",A1) - 1)
可以工作。
MID
takes start and length, FIND
returns the index of a given character. MID
采用start和length, FIND
返回给定字符的索引。
Edit: As pointed out, "Grade:" is fixed length so the following would work just as well: =MID(A1,7,FIND("/",A1) - 7)
编辑:正如所指出的,“等级:”是固定长度,因此以下也可以正常工作: =MID(A1,7,FIND("/",A1) - 7)
=SUBSTITUTE(SUBSTITUTE(C4, "Grade:", ""), "/2014-2015", "") = SUBSTITUTE(替换(C4,“等级:”,“”),“/ 2014-2015”,“”)
where C4 is the name of your cell. 其中C4是您的单元格的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.