Foxtable(狐表)用户栏目专家坐堂 → [求助]关于字符串分段


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

主题:[求助]关于字符串分段

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


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/2/10 15:23:00 [显示全部帖子]

'''...
Dim str As String = "关闭标志 is null and 完成入仓 = 'FALSE' and 组装车间_完成 = 'FALSE' and ( 产品名称 like '%777%' or 产品名称 like '%8301%')"
str = str.ToLower
Dim keys() As String = {" is ", " = ", " like "}
dim flts as new list(Of string)
Do While True
    Dim sidx As Integer = 0
    Dim eidx1 As Integer = str.IndexOf(" and ")
    Dim eidx2 As Integer = str.IndexOf(" or ")
    Dim eidx As Integer = -1
    If eidx1>=0 AndAlso eidx2>=0 Then
        eidx = math.Min(eidx1+1, eidx2)
    ElseIf eidx1>=0 Then
        eidx = eidx1+1
    ElseIf eidx2>=0 Then
        eidx = eidx2
    End If
    If eidx >= 0 Then
        Dim temp As String = str.SubString(sidx, eidx)
        output.show(temp)
        flts.add(temp.trim)
        str = str.SubString(eidx+4)
    Else
        Dim temp As String = str.SubString(sidx)
        output.show(temp)
        flts.add(temp.trim)
        Exit Do
    End If
Loop
output.show("------------------")
For Each flt As String In flts
    For Each key As String In keys
        Dim idx As Integer = flt.IndexOf(key)
        If idx >= 0 Then
            output.show(flt.SubString(0, idx))
            output.show(key)
            output.show(flt.SubString(idx+key.length))
            Exit For
        End If
    Next
Next


 回到顶部