![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Apr 2005
Posts: 126
Rep Power: 4
![]() |
Regular Expressions -_-
Alright I looked this up, and I cant find a good resource for writing regular resourses in VB.NET, I did find how to write them though, but im not sure what to do... can someone point me in the right direction, or maybe know a resource I could use on writing reg expressions, because I just modified an example and no matter what I do its not working...
Heres what I wrote: Dim rxpFileFormat As New Regex("(\w+) (\(\w+\))")
stFileFormat = rxpFileFormat.Replace(formFileNew.txtFileFormat, "$2")formFileNew.txtFileFormat is something like Text (.txt) and I am trying to define stFileFormat as what is between (), so with Text (.txt) it would become .txt. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Apr 2005
Posts: 126
Rep Power: 4
![]() |
Got it working finally, I was way off. There was a lot of problems when there was nothing to fill the array with to, because when array(2) or something was called the program would crash because it doesnt exist, it was never filled in the split if the user entered an invalid pattern, so I finally had to ReDim it, and put a max size in the beginning, anyways heres what worked:
Dim stFileFormat(2) As String stFileFormat = Regex.Split(formFileNew.txtFileFormat.Text, "([a-zA-Z0-9]*)\s\((.*)\)") ReDim Preserve stFileFormat(2) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|