Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 10th, 2005, 10:33 PM   #1
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
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.
brokenhope is offline   Reply With Quote
Old Sep 11th, 2005, 9:10 AM   #2
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
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)
brokenhope is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:11 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC