在Excel中提取String Beetwen 2字符

时间:2018-08-31 08:48:18

标签: excel excel-vba

我希望将A列中的字符串提取到每一列,其中字符串的位置介于“ d /”和“ / search”之间。

根据我创建的公式,它仅将其提取到一列中。

My Table

4 个答案:

答案 0 :(得分:2)

在单元格B2中,您已经具有以下公式:

=MID(A2,FIND("d/",A2)+2,FIND("/search",A2)-FIND("d/",A2)-2)

您真的很亲密,您只需要为以下公式添加起始位置作为参数即可,因此它将开始搜索先前找到的字符串,如下所示。

在C2中添加以下内容:

=MID(A2,FIND("d/",A2,FIND(B2,A2))+2,FIND("/search",A2)-FIND("d/",A2)-2)

在D2中,以下内容:

=MID(A2,FIND("d/",A2,FIND(C2,A2))+2,FIND("/search",A2)-FIND("d/",A2)-2)

答案 1 :(得分:1)

如果您具有Office 365 Excel,则可以使用一个公式来完成:

=CONCAT(IF(TRIM(MID(SUBSTITUTE(SUBSTITUTE($A2,"d/","|/",COLUMN(A:A)),"/",REPT(" ",99)),ROW($1:$100)*99,99))="|",TRIM(MID(SUBSTITUTE($A2,"/",REPT(" ",99)),ROW($2:$101)*99,99)),""))

这是一个数组公式,退出编辑模式时需要使用Ctrl-Shift-Enter而不是Enter进行确认。

enter image description here

答案 2 :(得分:1)

好吧,我当然不会重新键入您在图像中留下的所有示例数据,以供所有人重新键入,但请在B2中尝试然后向右和向下拖动,

enter image description here

答案 3 :(得分:0)

另一种方法,试试这个。

在单元格B2中应用以下公式

=TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," ")," ",REPT(" ",LEN(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," ")))), (2-1)*LEN(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," "))+1, LEN(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," "))))&", "&TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," ")," ",REPT(" ",LEN(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," ")))), (4-1)*LEN(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," "))+1, LEN(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," "))))&", "&TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," ")," ",REPT(" ",LEN(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," ")))), (6-1)*LEN(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," "))+1, LEN(SUBSTITUTE(SUBSTITUTE(A2,"d/"," "),"/search?"," "))))