我有一个格式如下的字符串:
StockCode Country Date Price equity
例如:
1 hk 10/31/12 C70.5 equity
101 hk 11/21/13 P63 equity
388 hk 10/17/12 P100 equity
我可以通过这个 Excel 命令提取日期:
LEFT(RIGHT(RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1)),
LEN(RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1)))-FIND(" ",
RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1)))),FIND(" ",
RIGHT(RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1)),
LEN(RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1)))-FIND(" ",
RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1))))))
(为了可读性而换行)
结果:10/31/12
有人对此有更好的解决方案吗?
这是我的一些代码:
如何获得“C”和“P”:
TRIM(MID(A1,IFERROR(FIND("P",A1),FIND("C",A1)),1))
如何获得行使价:
TRIM(SUBSTITUTE(RIGHT(A1,LEN(A1)-IFERROR(FIND("P",A1), FIND("C",A1))),"equity",""))