Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Windows Command Line Regular Expressions

I am having trouble finding how to execute regular expressions in Windows Command Line. I would want to use regular expressions for a number of situations, but basically now all I want to do is open a file with regular expressions in its name.

Example: Start s.html works fine, but start *.html does not work. What is needed?

Thanks

like image 750
Damien Golding Avatar asked Mar 21 '13 00:03

Damien Golding


People also ask

Can I use regex in CMD?

good to know that windows cmd line supports regex... but your example looks like glob, not regex.... good luck. Is this really about regular expression? Looks more like a simple wildcard match...


1 Answers

Unlike many Unix shells, the Windows command line processor does not expand wildcards automatically. It is each program's responsibility to expand wildcards as it sees fit. Many programs simply don't support wildcards at all. In those cases you can always create a FOR loop to repeatedly issue the same command on a set of files specified by a wildcard.

e.g. for %f in (*.txt) do echo %f

will echo the names of all *.txt files in a directory.

use the help command to get more detailed help on any Windows command. i.e.

help for

As for regular expressions: other than findstr, I don't know of any built-in Windows command which supports regular expressions.

like image 174
Ferruccio Avatar answered Nov 08 '22 18:11

Ferruccio