Excel - 删除特定字符后的字符

时间:2021-10-22 20:06:15

I have colum B with values:

我有colum B的值:

0015-04D-SEAW
0015-ADLKM-SPOK
0015-D-CURR
0016-01N-BOIL etc.

0015-04D-SEAW 0015-ADLKM-SPOK 0015-D-CURR 0016-01N-BOIL等

How can I remove all characters after second dash and the second dash itself as well, it should look like this:

如何删除第二个破折号后的所有字符以及第二个破折号本身,它应如下所示:

0015-04D
0015-ADLKM
0015-D
0016-01N

0015-04D 0015-ADLKM 0015-D 0016-01N

2 个解决方案

#1


1  

One dirty solution would be to convert text to columns delimited by - and then to concatenate the first two columns separated by -

一个肮脏的解决方案是将文本转换为由 - 分隔的列 - 然后连接由 - 分隔的前两列 -

#2


2  

Assuming B1 contains 0015-04D-SEAW

假设B1包含0015-04D-SEAW

This would do : =IFERROR(MID(B1,1,FIND("-",B1,FIND("-",B1,1)+1)-1),B1)

这样做:= IFERROR(MID(B1,1,FIND(“ - ”,B1,FIND(“ - ”,B1,1)+1)-1),B1)

Result : 0015-04D

结果:0015-04D

#1


1  

One dirty solution would be to convert text to columns delimited by - and then to concatenate the first two columns separated by -

一个肮脏的解决方案是将文本转换为由 - 分隔的列 - 然后连接由 - 分隔的前两列 -

#2


2  

Assuming B1 contains 0015-04D-SEAW

假设B1包含0015-04D-SEAW

This would do : =IFERROR(MID(B1,1,FIND("-",B1,FIND("-",B1,1)+1)-1),B1)

这样做:= IFERROR(MID(B1,1,FIND(“ - ”,B1,FIND(“ - ”,B1,1)+1)-1),B1)

Result : 0015-04D

结果:0015-04D