Monday, September 3, 2018

findstr supports wildcards in the form of regular expressions

One user wanted to use a batch script to search for a wildcard-enabled pattern in a file. findstr can do this, but with a somewhat different wildcard format. A period matches any single character (the equivalent of a question mark in usual batch wildcard style). Putting an asterisk after the period to make .* matches any run of characters, the equivalent of an asterisk in the usual batch style. Supplying the /c switch disables regex support and uses the pattern as a literal string. The end of the output of findstr /? has a quick regex reference.

No comments:

Post a Comment