Hello ,
I tried a code which reads the file InputFile.txt (attached) grep particular values and write it to a file in a desired output format is in file OutputFile.txt
Below is the code partially I have done.. -
-
Dim re, targetString, colMatch, objMatch, nMT
-
-
Set objFS = CreateObject("Scripting.FileSystemObject")
-
-
Set rs = New RegExp
-
-
strFileIN = "..\Inputfile.txt"
-
strFileOUT = "..\Outputfile.txt"
-
-
With rs
-
.Pattern = "\w+\(\w\.+\)" & "\w+\(\w+\)"
-
.Global = True
-
.IgnoreCase = True
-
End With
-
-
Set objFile = objFS.OpenTextFile(strFileIN)
-
strText = objFile.ReadAll
-
-
-
-
Set colMatch = rs.Execute(strText)
-
-
Set objOutFile = objFS.CreateTextFile(strFileOUT,True)
-
-
-
For nMT = 0 To colMatch.Count - 4
-
-
objOutFile.WriteLine colMatch(nMT + 0) &" "& colMatch(nMT + 1) &" "& colMatch(nMT + 2) &" "& colMatch(nMT + 3)
-
-
Next
-
-
-
-
objOutFile.Close
-
-
Help me on correcting my code to get to my desired output as in file OutputFile.txt.
10 2640
You haven't said what is wrong with the code. Not working is too general a statement.
Also, since VBS is closer to VBA than VB6, I'm moving this to the Access forum where you may get more help.
QUEUE(TEST.QA.Q1) TYPE(QLOCAL)
CURDEPTH(0) MAXDEPTH(100000)
On my inputfile.txt , How do I form the regular expression pattern to match above pattern's. pls note word "TEST.QA.Q1" may change and the words delimited by "." dots may vary in numbers.
The pattern That i formed in my code didn't match QUEUE(TEST.QA.Q1).
Your regex pattern is malformed. It should be \w+\([\w\.]+\)
Thanks Rabbit . It worked. I will try my code.
- QUEUE(Q1.A1.C3.TEMP) TYPE(QLOCAL)
-
CURDEPTH(0) MAXDEPTH(1000)
How to take values between ( and ) parenthesis and assign it to a variable ? I tried with mid function, but since my number of characters change it is not a solution. Do we have a special function ? - QUEUE=Q1.A1.C3.TEMP TYPE=QLOCAL CURDEPTH=0 MAXDEPTH=1000
You already have the pattern, it's the one I posted earlier.
Corrected my question to be specific. Please check now.
You can use the replace function.
You are probably looking after placeholders ($1, $2) to use the expression you put between parenthesis in your regular expression. Here is an exemple I have in my codes. It takes a line of text, search for numbers having a negative sign at the end and move it at the beginning of the number. - Function BringForwardNegativeSign(LineToFix As String) As String
-
'This is to put negative sign in front 6.54- to -6.54 that exist in the DRMIS file.
-
Dim re As New RegExp
-
re.pattern = "\|( +)([0-9]*,?[0-9]*,?[0-9]*\.[0-9]{2})-"
-
re.Global = True
-
If (re.test(LineToFix) = True) Then
-
BringForwardNegativeSign = re.Replace(LineToFix, "|$1-$2")
-
Else
-
BringForwardNegativeSign = LineToFix
-
End If
-
End Function
-
I'd just like to mention here that Instr() may be the function you were looking for. It searches a string for another string and tells you where (or whether) it occurs.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: chuck amadi |
last post by:
By the way list is there a better way than using the readlines() to
> > >parse the mail data into a file , because Im using
> > >email.message_from_file it returns
> > >all the data i.e reads one...
|
by: Andrew Slentz |
last post by:
I have a format file which is working but not correctly. It is, for
some reason, dropping the first line of the input .csv file. The
problem is something with the second coulumn of data having...
|
by: Query Builder |
last post by:
I am new to BCP. Can anyone help me understand this? I tried searching
the BOL but it doesnt show much help on syntex. Lets say I have a
simple table and want to out put the records into a file....
|
by: Paul Watson |
last post by:
It is clear that just using 'print' with variable names is relatively
uncontrollable. However, I thought that using a format string would
reign the problem in and give the desired output.
Must...
|
by: Paolo Pignatelli |
last post by:
I am trying to get an output/file like this (below) in an XML file
(MyXmlFile.xml) (which I will use for a slide show)
--
<gallery timer="3" order="sequential" fadetime="2" looping="yes"...
|
by: neon123 |
last post by:
i am using a sql loader to load data into oracle 8.
i am using vbscript to run the sql loader.
i need to pass username and password entered through vbscript ,,into the visual basic application .
...
|
by: tudyfruity18 |
last post by:
I have to write a program that will reformat the data files given to me and create a new data file for each city. The desired output would be the cities name followed by the year( fixed four digits),...
|
by: Chris Ashley |
last post by:
I have a stream of bytes (making up a large file) coming from
somewhere, and need to send it to the user. I can't send it to
Response.OutputStream because this is read only, and storing the
entire...
|
by: Soniad |
last post by:
Hello,
I want to include asp file within vbscript, this file name i am taking in variable .
and when i use this variable in the include tag outside delimiters(<%%>), it does not work,
<%Dim...
|
by: zizi2 |
last post by:
Hi,
how do I output multiple excel files from one source using vbscript?
Regards,
Noluthando
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |