VB.NET 2003
Right now the regex below is not pulling these number sequences (below)
Question:
1. I did not know if some of the regex expressions I have here will work.
' code ====================================================
With dbDataSet.Tables("tblData")
For Each dbRow As Data.DataRow In dbDataSet.Tables("tblData").Rows
Dim input As String = dbRow.Item("fldDescription")
Dim pattern1 As String = "(\s|^)(\d\w{3,}|\w(?=\w*?\d)\w{3,})(\s|$)" '4 or more in Digit/AlphaNumx 3 in length
'Dim pattern1 As String = "(\s|^)(\d\w{3,})(\s|$)" '4 or more in Digit/AlphaNumx 3 in length
'Dim pattern As String = "(\s|^)(\d{4,})(\s|$)" '4 or more in length
'Dim pattern As String = "(\s|^)(\d+)(\s|$)" ' WORKING for anynumber
'Dim pattern As String = "(\s+\d+\s+)"
Dim mc As MatchCollection = Regex.Matches(input, pattern1)
Dim output As String = ""
Dim trimStr() As Char = {" "c, ":"c}
For Each m As Match In mc
output &= m.Groups(0).Value & " : "
Next
' Remove the last " : " in the output string.
dbRow.Item("fldMfrnum") = output.TrimEnd(trimStr)
Next
' =code =======================================
SHEAVE , PT-H504 , IDLE
PULLEY , SLG125S , 1/2 INCH
FUSE , 125S , GLASS
PULLEY , PT-I303
BUSHING , PT-F902
BUSHING , PT-N604 , IDLE
FUSE , W24 , 7 AMP
FUSE , w56 , 5 AMP
V-BELT , B81
V-BELT , A-45
MASKING TAPE , 41-3220-0 , 1/2 INCH ROLE
PT-H504
SLG125S
125S
PT-I303
PT-F902
PT-N604
W24
w56
B81
A45
41-3220-0
Trying to match additional numbers embedded in strings
Thanks
fordraiders
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.