简体   繁体   English

从一串文本中提取数字 - Excel

[英]extract number from a string of text - Excel

I'm trying to pull a number out of the middle of a string of text in excel. 我试图从excel中的一串文本中间拉出一个数字。 the string is a mixtire of alpha, numeric and some characters. 字符串是alpha,numeric和一些字符的混合。

Example data string:- 示例数据字符串: -

Web Address 
/products_list.php?retailer=8&cat=43
/products_list.php?retailer=22&cat=43
/products_list.php?retailer=8&cat=1011
/products_list.php?retailer=81&cat=1023
/products_list.php?retailer=147&cat=1224
/products_list.php?retailer=8&cat=1
/products_list.php?retailer=147&cat=4
/products_list.php?retailer=147&cat=401

What i want to achieve is 我想要实现的是

例子excel

I got as far as pulling out all the numbers from the text but really couldn't work out how to just get the numbers in the middle or the ones at the end. 我从文本中删除所有数字,但实际上无法解决如何在中间或最后得到数字。

My attempted code to fix the issue was:- 我尝试修复此问题的代码是: -

=SUM(MID(0&A3,LARGE(ISNUMBER(--MID(A3,ROW(INDIRECT("1:"&LEN(A3))),1))*ROW(INDIRECT("1:"&LEN(A3))),ROW(INDIRECT("1:"&LEN(A3))))+1,1)*10^ROW(INDIRECT("1:"&LEN(A3)))/10)

SCE for an array formula. SCE为数组公式。

If possible, I would prefer a formula over a macro. 如果可能的话,我更喜欢宏观上的公式。

oh in case it makes a difference im using Excel 2010. 哦,以防它使用Excel 2010有所作为。

Retailer (B2): 零售商(B2):

=LEFT(RIGHT(A2,LEN(A2)-FIND("=",A2)),FIND("&",RIGHT(A2,LEN(A2)-FIND("=",A2)))-1)

Cat Number (C2): 卡特彼勒号码(C2):

=RIGHT(A2,LEN(A2)-(FIND("cat=",A2)+3))

drag the formula down and 拖动公式并且

在此输入图像描述

This looks really ugly (I am no excel expert), but it worked with the list you provided. 这看起来很丑陋(我不是excel专家),但它适用于你提供的列表。

Formula for retailer: 零售商的公式:

=MID(A2,FIND("retailer=",A2)+9,FIND("&",A2)-(FIND("retailer=",A2)+9))

Formula for cat number: 猫号公式:

=MID(A2,FIND("cat=",A2)+4,100)

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

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