|
-
Jan 3rd, 2007, 06:41 AM
#1
Thread Starter
Member
Help with Regular expressions
Hi everyone,
got in a bit of a mess trying to use regex. I had a look in the forums and picked up bits that I might need but could not quite figure out how it works.
I am trying to split a line of delimited data using the split function which works fine until for example I come accros something like this
"Hello","World","Hello,World" which when using "," as the delimiter gives me 4 elements in my array rather than 3. I know I could use (",") this as my delimiter but would this be the most efficient way of doing this?
Oh, I nearly forgot AND I get an error (run-time error 5017) when I try and do my replace.
Thanks your your help
Gogi
VB Code:
Private Sub Command1_Click()
Dim mainFile As Integer
Dim text As String
Dm regEx As New RegExp 'Regular Expression object
Dm str1 As String
Dim strReplace As String
Dim Delimiter As String
mainFile = FreeFile
Open "C:\test data\test.txt" For Binary As mainFile
Seek mainFile, 1
Line Input #mainFile, text
Delimiter = ","
regEx.Pattern = "(?<="")[^" & Delimiter & "].*?[^" & Delimiter & "](?="")"
str1 = text
strReplace = "~"
Debug.Print str1
str1 = regEx.Replace(str1, strReplace)
Debug.Print str1
end sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|