以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  数字字母单独提取  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=107912)

--  作者:huhuyq
--  发布时间:2017/10/12 13:43:00
--  数字字母单独提取
各位大神,有什么方法将下面的字段提取成单独的列,如下表所示
           Line No                               Area                Fluid        Circuit       Line        Train
P055AZOR-01RG00-1599-20            01                   RG           00            1599        20
P055AZOR-02P02-0105-01              02                    P             02            0105        01

关键就是黄色高两部分的字母和数字的区分,谢谢了!


--  作者:有点甜
--  发布时间:2017/10/12 14:19:00
--  
\'Dim str As String = "01RG00"
Dim str As String = "01R00" \'
Dim mc = System.Text.RegularExpressions.Regex.Matches(str, "[0-9]+|[a-zA-Z]+")
If mc.count = 3 Then
    msgbox(mc(1).value)
End If

--  作者:huhuyq
--  发布时间:2017/10/12 15:50:00
--  
大神能不能具体一点啊?那个命令没看懂啊。
--  作者:有点甜
--  发布时间:2017/10/12 16:20:00
--  

datacolchanged事件

 

Select Case e.DataCol.Name
    Case "第一列"
        If e.DataRow.IsNull("第一列") Then
            e.DataRow("第二列") = Nothing
            e.DataRow("第三列") = Nothing
        Else
            Dim str As String = e.DataRow("第一列")
            Dim ary() As String = str.split("-")
            Dim mc = System.Text.RegularExpressions.Regex.Matches(ary(1), "[0-9]+|[a-zA-Z]+")
            If mc.count = 3 Then
                e.DataRow("第二列") = mc(0).value
                e.DataRow("第三列") = mc(1).value
                e.DataRow("第四列") = mc(2).value
            End If
            e.DataRow("第五列") = ary(2)
            e.DataRow("第六列") = ary(3)
        End If
End Select


--  作者:huhuyq
--  发布时间:2017/10/12 16:36:00
--  
已明白,谢谢大神