简体   繁体   English

Excel删除字符串中最后一个“ |”字符之前的文本

[英]Excel remove text before last “|” character in string

I have some multiple images in Excel file which are separated with | 我在Excel文件中有一些以|分隔的图像 For example: 例如:

http://s3.supplyhouse.com/images/products/small/gt2700-15-3.jpg|http://s3.supplyhouse.com/images/products/small/gt2700-15-4.jpg|http://s3.supplyhouse.com/images/products/small/gt2700-15-1.jpg

I want to extract the last image from the cell. 我想从单元格中提取最后一张图像。

I need to configure =RIGHT formula that will remove all text before last | 我需要配置=RIGHT公式,该公式将删除last |所有文本| character. 字符。

In some cells there are | 在某些单元格中| characters 3 times, somewhere, 2, somewhere 4. So I need to find the last one and delete all characters before it, I don't need something like "Find 3rd | character and remove everything before it". 字符3次,在某处2次,在某处4次。因此,我需要找到最后一个并删除之前的所有字符,不需要“查找第3个|字符并删除之前的所有字符”之类的内容。

I have combined some excel formulas and made this one which works: 我结合了一些excel公式,并使之有效:

=RIGHT($D1,LEN($D1)-SEARCH("^^",SUBSTITUTE(D1,"|","^^",LEN(D1)-LEN(SUBSTITUTE(D1,"|","")))))

If someone think that something is missing, please comment. 如果有人认为缺少某些东西,请发表评论。

To get just the image filename, 要仅获取图像文件名,

=TRIM(RIGHT(SUBSTITUTE(A2,"/",REPT(" ",LEN(A2))),LEN(A2)))

To get the full link, 要获取完整链接,

=TRIM(RIGHT(SUBSTITUTE(A2,"|",REPT(" ",LEN(A2))),LEN(A2)))

在此处输入图片说明

Cleaner way to do this would be to have 1 formula to identify image breaks and then another formula to give the picture string. 较干净的方法是使用1个公式来识别图像中断,然后使用另一个公式来给出图片字符串。 Then just use an offset function to capture the last image for your answer. 然后,只需使用偏移功能即可捕获最后一张图像作为答案。

Note:I inserted your picture string into A1 注意:我将您的图片字符串插入A1

Column 1: Image # 第1栏:图片#

Column 2: String for each picture =IFERROR(SEARCH(".jpg",$A$1),"") 第2列:每张图片的字符串= IFERROR(SEARCH(“。jpg”,$ A $ 1),“”)

Column 3: Text for picture: =IFERROR(LEFT($A$1,B4+3),"") 第3列:图片文字:= IFERROR(LEFT($ A $ 1,B4 + 3),“”)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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