[这个贴子最后由YBIL在 2008/04/12 11:09am 第 3 次编辑]
1、一翻多的方法:
一翻二("A|B|C"→"A@A|B@B|C@C"):
Eval("Substitute(""|@|"",""|"","""+Substitute("A|B|C","|",""")+""|""+Substitute(""|@|"",""|"",""")+""")")
一翻三("A|B|C"→"A@A#A|B@B#B|C@C#C"):
Eval("Substitute(""|@|#|"",""|"","""+Substitute("A|B|C","|",""")+""|""+Substitute(""|@|#|"",""|"",""")+""")")
一翻四("A|B|C"→"A@A#A&A|B@B#B&B|C@C#C&C"):
Eval("Substitute(""|@|#|&|"",""|"","""+Substitute("A|B|C","|",""")+""|""+Substitute(""|@|#|&|"",""|"",""")+""")")
2、合并字符
⑴:("A|B"+"1|2"→"A#1@A#2|B#1@B#2")
Eval("mid(Substitute(""|1|2"",""|"",""@"+Substitute("A|B","|","#""),1)+""|""+mid(Substitute(""|1|2"",""|"",""@")+"#""),1)")
⑵: ("A|B|C"+"1|2|3"→"A@1|B@2|C@3")
Eval(rept("Substitute(",len("A|B|C")-len(Substitute("A|B|C","|",""))+1)+""""+"A|B|C"+"|"",""|"",""#"+Substitute("1|2|3","|","@"",1),""|"",""#")+""",1)")
注:俺原先进行一翻多是在eval("Mid(Rept(""@"+Substitute("A|B|C","|",""",2),1)+""|""+Mid(Rept(""@")+""",2),1)")一翻二的基础上参照一翻二的方法,翻下去,翻得多了公式没什规律,受gdlgh兄启发(在此多谢gdlgh兄了^-^),发现一翻多公式可以这样,公式通用,只要改变您喜欢的分隔符(用N-1个不同分隔符分隔)即可,较为常用的是一翻二和一翻三。
如文件中模糊匹配应用公式实际是:
ReplaceFor(Grid,"简称","按摩医院","进货单位","Instr","按摩医院") And ReplaceFor(Grid,"简称","北京大学第三医院","进货单位","Instr","北京大学第三医院") And ReplaceFor(Grid,"简称","北京同仁京苑医院","进货单位","Instr","北京同仁京苑医院") And ReplaceFor(Grid,"简称","广安门医院","进货单位","Instr","广安门医院") And ReplaceFor(Grid,"简称","广外医院","进货单位","Instr","广外医院") And ReplaceFor(Grid,"简称","护国寺中医院","进货单位","Instr","护国寺中医院") And ReplaceFor(Grid,"简称","隆福医院","进货单位","Instr","隆福医院") And ReplaceFor(Grid,"简称","人民医院(北)","进货单位","Instr","人民医院(北)") And ReplaceFor(Grid,"简称","仁和医院","进货单位","Instr","仁和医院") And ReplaceFor(Grid,"简称","铁路分局医院","进货单位","Instr","铁路分局医院") And ReplaceFor(Grid,"简称","铁营医院","进货单位","Instr","铁营医院") And ReplaceFor(Grid,"简称","同仁医院","进货单位","Instr","同仁医院") And ReplaceFor(Grid,"简称","望京医院(北)","进货单位","Instr","望京医院(北)") And ReplaceFor(Grid,"简称","协和医院","进货单位","Inst