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 Comments2 Solutions505 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

ASKER CERTIFIED SOLUTION
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 2 Answers and 16 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 2 Answers and 16 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004