VBScript - Find text in a txt file using regular expressions and write to another output file

Good afternoon,

I am looking for a way in a VBScript to find text based on a regular expression search pattern and write that output to another file (taking into account that the search pattern may need to return more than one result).  I have found a lot of resources on replacing text strings in a txt file which is fairly simple but little on selecting text in a file based on a regular expression, capturing it as a string, and writting this string to another output file.  Any links or code examples would be appreciated.  I am executing this from a batch file with the cscript command line utility.

Thanks!
LVL 1
orionpmAsked:
Who is Participating?
 
Clever_BobConnect With a Mentor Commented:
I can give you some guidance anyway and I hope this helps point you in the right direction.

1) Your VBScript code needs to declare the filesystem object
2) point the filesystem object in the direction of your text file
3) read the contents of the text file into a local variable
4) make the changes using the 'replace' command or grab the text you need using 'instr' and a combination of string manipulation commands (left, mid etc)
5) write the variables to your new text file using the filesystem object again
6) close the filesystem object

Hope this helps!
0
 
orionpmAuthor Commented:
Thanks, the issue I was having was grabbing the text I read using regular expressions.  After sifting through the Micorosoft documentation on this I am able to pass my regular expression in as an argument from the command line which is working great.  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.