I have a text file which is like this
29/8/2004 dsadsa dadsad email@example.com tfdsfce m rfdsfson2l43 Hadfsdand Rd. Frdsfsin GN 50033
5545163111 3338544355 Anytime VG337612 TN476757 Vn5676982 0.067 6700
I want to do pattern matching in this file and do some manipulations.
I want to find all 5 digit integers in the file and leave double space before and after it.
eg: GN 50033 5545163111 : here my output should be GN 50033 5545163111
I want to find all 2 consecutive capital characters and leave single space before and after
eg: Rd. Frdsfsin GN50033 : output should be Rd. Frdsfsin GN 50033
I want to find all 10 digit intergers and put comma before and after it
eg: 67003.5 7222233339N.A : output : 67003.5,7222233339,N.A
There are so many such patterns that are to be identified and processed. I have tried with most of the VB string functions and they are not much of an help.
Can anyone provide me with a start. If you can provide a clue or idea for how to do this type of pattern matching, I can solve all the patterns.
Dim intMsg As String Dim StudentName As String Open "F:\source.txt" For Input As #1 Dim filedata As String Dim tmp As String Dim contents As String While EOF(1) = 0 Line Input #1, tmp contents = contents + tmp Wend Close #1
Using the above code i have stored all the contents of the file into a string named "contents".
So i have the data in the string format. I have already completed around 11 pattern matching using the basic string functions. There are 13 more patterns to be matched which require some special functions which i am not aware of.