Equivalent of a wildcard in find for batch?
I'm almost certain this is a duplicate but I was unable to find it after a lot of searching so forgive me.
I'm looking for a way to have the equivalent of a wildcard in the find command. For instance, If I want to find a line in a file that has 09/(some unknown string here)/2018 How would I go about doing this? I'm open to using the findstr command too.
1 Answer
findstr supports some simple regular expressions - see the bottom of the output of findstr /?. To match any run of characters, use .*. The dot matches any single character, and the asterisk allows matching the previous character (any character, in this case) any number of times. So this will find any lines that contain 09/ and /2018 with any characters in between:
findstr "09/.*/2018" MYFILE.TXTIf you only want to match lines where the unknown string is exactly two characters long (since your search string appears to be a date), just use two single-character wildcards:
findstr "09/../2018" MYFILE.TXT 5