Foxtable(狐表)用户栏目专家坐堂 → [求助]字符串是否包含数组关键字


  共有3346人关注过本帖树形打印复制链接

主题:[求助]字符串是否包含数组关键字

帅哥哟,离线,有人找我吗?
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110592 积分:562856 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/7/27 11:47:00 [显示全部帖子]

'''
Dim str As String = "根据《行政诉讼法》第三条第二款之规定"
Dim lst As New List(of String)
lst = Tables("表A").Current.DataRow.Lines("第一列")
For Each ls As String In lst
    Dim ss() As String = ls.Split("、")
    Dim p As Boolean = True
    For i As Integer =  0 To ss.count - 1
        If str.Contains(ss(i)) = False Then
            p = False
            Exit For
        End If
    Next
    If p Then
        msgbox(true)
        Exit For
    End If
Next

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110592 积分:562856 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/9 15:12:00 [显示全部帖子]

自行调试

For Each s As String In ary    '遍历段落
            If s.trim() > "" Then

output.show(ls.count & " = " & s)

                ls.add(s)    '将段落加入集合

                For Each s1 As String In str1.split("|")      '判断是否包含st1关键字

output.show("s1 = " & s1)

                    Dim ss1() As String = s1.Split("、")
                    Dim lst1 As New List(of String)           '关键字新集合
                    lst1.AddRange(ss1)
                    Dim p As Boolean = True
                    For i As Integer =  0 To lst1.count - 1
                        If s.Contains(lst1(i)) = False Then

output.show("包含 = " & lst1(i))
                            p = False‘表示找到,这里p=false
                            Exit For
                        End If
                    Next

output.show("p = " & p)
                    If p Then 'p=true,这里表示的是没有找到
                        ' msgbox(true)
                        i1 = ls.count-1
                        msgbox(i1)
                        Exit For
                    End If
                Next
                
            End If
        Next


 回到顶部