简体   繁体   English

MS Excel:计算文本字符串中两个不同字符之间的单词数

[英]MS Excel: Count Number of Words Between Two Different Characters in a Text String

I am looking for a MS Excel (2007 or 2010) formula that will return the number of words found between two (2) specific characters within a text string. 我正在寻找一个MS Excel(2007或2010)公式,该公式将返回文本字符串内两(2)个特定字符之间找到的单词数。

Example (In Cell A2): John Doe purchased a pizza for $13.00 using his 10% discount coupon on his order. 示例(在A2单元中):John Doe使用他的订单的10%折扣优惠券以$ 13.00的价格购买了一个披萨。

I would like to Count the number words separated by spaces between the "$" (dollar symbol) and the "%" (percent symbol); 我想计算用“ $”(美元符号)和“%”(百分比符号)之间的空格隔开的数字单词; including the words containing the specific characters. 包括包含特定字符的单词。

Results (In Cell B2): The formula in cell A2 returns a value of four (4) to reflect that the string contains four words ($13.00 using his 10%) separated by "$" and "%". 结果(在单元格B2中):单元格A2中的公式返回值四(4),以反映该字符串包含四个单词($ 13.00,使用其10%的百分比),并用“ $”和“%”分隔。

将其放置在B2中,根据需要更改“%”和“ $”:

=LEN(MID(B2,FIND("$",B2)+1,FIND("%",B2)-FIND("$",B2)-1))-LEN(SUBSTITUTE(MID(B2,FIND("$",B2)+1,FIND("%",B2)-FIND("$",B2)-1)," ",""))+1

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

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