以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 连续相同字符串筛选问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=188608) |
-- 作者:ZJZK2018 -- 发布时间:2023/10/4 23:11:00 -- 连续相同字符串筛选问题 连续相同字符串筛选配对问题,如何做成下图中红线精确配对???第二列的数据是标准的 下面代码出现多个值? Dim str As String = "投标单位|投标报价|项目负责人|质量标准|工期|投标保证金|信用分|资信分值|技术分值|开标备注|评标备注|标书备注|联合体成员|序号" Dim stt As String = "投标单位名称|投标总价(元)|项目经理|质量标准|工期(天)| 投标保证金缴纳情况|信用分值|资信分值|技术分值|开标备注|评标备注|标书备注|联合体成员|序号" For Each st As String In stt.Split("|") If st > "" Then For i As Integer = 0 To st.Length - 2 Dim s As String = st.Substring(i, 2) \'连续二个字符相同 For Each nm As String In str.Split("|") If nm.Contains(s) Then \'nr("接收表列名") = nm \'自动选出列名 Output.Show(nm) End If Next Next End If Next [此贴子已经被作者于2023/10/4 23:33:55编辑过]
|
-- 作者:有点蓝 -- 发布时间:2023/10/7 11:31:00 -- Dim str As String = "投标单位|投标报价|项目负责人|质量标准|工期|投标保证金|信用分|资信分值|技术分值|开标备注|评标备注|标书备注|联合体成员|序号" Dim stt As String = "投标单位名称|投标总价(元)|项目经理|质量标准|工期(天)|投标保证金缴纳情况|信用分值|资信分值|技术分值|开标备注|评标备注|标书备注|联合体成员|序号" Dim dict As New Dictionary(Of String, String) For Each st As String In stt.Split("|") If st > "" Then For Each nm As String In str.Split("|") If dict.ContainsKey(st) AndAlso dict(st).Split("|")(0).Length >= nm.Length Then Continue For For i As Integer = nm.Length To 2 Step - 1 If dict.ContainsKey(st) AndAlso dict(st).Split("|")(0).Length >= i Then Continue For Dim b As Boolean = False For k As Integer = 0 To nm.Length - i Dim nmm As String = nm.Substring(k, i) If st.Contains(nmm) Then If dict.ContainsKey(st) Then If dict(st).Split("|")(0).Length < nmm.Length Then dict(st) = nmm & "|" & nm End If Else dict.Add(st, nmm & "|" & nm) End If \'nr("接收表列名") = nm \'自动选出列名 \' Output.Show(st & " => " & nm & " : " & k & "," & i & "=" & nmm) b = True Exit For End If Next If b Then Exit For End If Next Next End If Next For Each key As String In dict.Keys Output.Show(key & "=>" & dict(key)) Next
|
-- 作者:ZJZK2018 -- 发布时间:2023/10/8 9:10:00 -- 老师2楼代码得出的值还是有重复值,我只需要一个值,怎么办? |
-- 作者:有点蓝 -- 发布时间:2023/10/8 9:18:00 -- 我测试没有问题,哪个值重复了? |