Wednesday, July 25, 2007

Regex Using Findstr

OK, so I'm reeeeally busy these days, and I only have time to post a lame-ass topic like this one.  I mean, who wouldn't know about using findstr to search for regular expressions in a file, right?

Anyway, to do that you all you have to do is pass the /R option, and put the regular expression as /C option argument.  Say you want to search for every lines in a file that begins with a Foo and ends with a Bar, with any string in between.

findstr /R /C:"^Foo.*Bar$" some.txt

To make it search recursively in a directory, use the /S option.  If you want to ignore case, use the /I option.

OK, gotta go.

No comments: