troubleshooting Question

Regex Expression Updated for alphaNumeric or Numeric sequences

Avatar of Fordraiders
FordraidersFlag for United States of America asked on
Visual Basic.NET
16 Comments1 Solution505 ViewsLast Modified:
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

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 16 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros