Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

Batch: extract text using reg exp in windows bat file

Jul 7, 2013 6:21AM PDT

Howdy! Novice question:

I can use the following regular expression

(?<=\[)(.*?)(?=\])

in textcrawler (a gui based Windows grep program) to extract text in between two brackets into another file. it works beautifully.

However, I need to be able to do that from a Windows bat file. Something like

grep (?<=\[)(.*?)(?=\]) myinput.txt >myoutput.txt (well..you get the idea)

I have tried numerous versions of command line grep programs for windows, but just cannot for the life of me find one that works (or more accurately, figure out the syntax to go get it to work.)

(sometimes just putting the reg expression in a bat file screws up the processing, so it sound like I need syntax help)

Thanks in advance...

Discussion is locked