我正在尝试从单个单元格中的非常长的字符串中提取某些数据。为了这个练习,这是我在单元格A1中的数据。
一个:2:{S:15: “info_buyRequest”;一个:5:{S:4: “uenc”; S:252: “WN0aW9uYWwuaHRlqdyZ2dC1hdD0lN0JhZHR5cGUlN0QmdnQtcHRpPSU3QmFkd29yZHNfcHJvZHVjdHRhcmdldGlkJTdEJiU3Qmlnbm9y,”; S:7: “产品”; S:4: “1253”; S:8: “form_key”; S:16: “wyfg89N”; S:7: “选项”;一个:6:{I:10144; S:5: “73068”; I:10145; S :5: “63085”; I:10141; S:5: “73059”; I:10143; S:5: “73064”; I:13340; S:5: “99988”; I:10142; S:5 : “73063”;} S:3: “数量”; S:1: “1”;} S:7: “选项”;一个:6:{I:0;一个:7:{S:5:”标签 “; S:5:” 彩色 “; S:5:” 值 “; S:11:” 白 “; S:11:” print_value “; S:11:” 白 “; S:9:” option_id” ; S:5: “10144”; S:11: “option_type”; S:9: “DROP_DOWN”; S:12: “请将option_value”; S:5: “73068”; S:11: “custom_view”; b :0;} I:1;一个:7:{S:5: “标签”; S:4: “裁剪”; S:5: “值”; S:11: “黑色”; S:11:” print_value “; S:11:” 黑色 “; S:9:” option_id “; S:5:” 10145 “; S:11:” option_type “; S:9:” DROP_DOWN “; S:12:” 请将option_value” ; S:5: “63085”; S:11: “custom_view”; b:0;} I:2;一个:7:{S:5: “标签”; S:7: “材料”; S:5 “值”; S:15: “乙烯基”; S:11: “print_value”; S:15: “乙烯基”; S:9: “option_id”; S:5: “10141”; S:11:” option_type “; S:9:” DROP_DOWN “; S:12:” 请将option_value “; S:5:” 73059" ; S :11: “custom_view”; B:0;} I:3;:7:{S:5: “标签”; S:6: “方向”; S:5: “值”; S:17:”左侧“; s:11:”print_value“; s:17:”左侧“; s:9:”option_id“; s:5:”10143“; s:11:”option_type“; s:9:” DROP_DOWN “; S:12:” 请将option_value “; S:5:” 73064 “; S:11:” custom_view “; b:0;} I:4;一个:7:{S:5:” 标签“; S :12: “表”; S:5: “值”; S:16:“YES!添加表“; s:11:”print_value“; s:16:”是的!添加表“; s:9:”option_id“; s:5:”13340“; s:11:”option_type“; s:9:”drop_down“; s:12:”option_value“; s:5:”99988 “; S:11:” custom_view “; b:0;} I:5;一个:7:{S:5:” 标签 “; S:8:” 送货 “; S:5:” 值“; S: 20:“Front Door Delivery”; s:11:“print_value”; s:20:“Front Door Delivery”; s:9:“option_id”; s:5:“10142”; s:11:“option_type”; S:9: “DROP_DOWN”; S:12: “请将option_value”; S:5: “73063”; S:11: “custom_view”; b:0;}}}
最终结果是分离颜色,修剪,材质方向等的值
我使用的公式是:
=MID(LEFT(A4,FIND("print_value",A4)-9),FIND("Color",A4)+25,LEN(A4))
这基本上是在两个点之间查看并修剪出脂肪。它可以工作,但仅适用于“print_value”的第一次迭代。如果我用这个搜索“修剪”......
=MID(LEFT(A4,FIND("print_value",A4)-9),FIND("Trim",A4)+25,LEN(A4))
...我得到一个空的结果。发生这种情况是因为print_value是重复的而不是字符串唯一的。 Excel不明白将其功能应用到什么点并使自己发挥作用。
尽管这个字符串中有一些独特的因素我可以将自己附加到(并得出所需的结果),但我不能使用它们,因为它们不一致并且在应用于其他单元格时会使公式无效
那说,这就是我需要的。在这个公式中,我需要一种方法来A)告诉公式找到print_value的哪个迭代,或者B)将print_value改为print_value(1,2,3,4等),然后运行我的修剪公式。
答案 0 :(得分:0)
基于此link的几个选项:
1)VBA - 使用用户定义的功能
如果您对这些内容不熟悉,请按照此tutorial。
Function FindN(sFindWhat As String, _
sInputString As String, N As Integer) As Integer
Dim J As Integer
Application.Volatile
FindN = 0
For J = 1 To N
FindN = InStr(FindN + 1, sInputString, sFindWhat)
If FindN = 0 Then Exit For
Next
End Function
2)使用公式
=FIND(CHAR(1),SUBSTITUTE(A1,"c",CHAR(1),3))