Search code examples
regexfindstr

problem while using findstr


I am trying to execute the following pattern in findstr. The findstr is complaining that the

)]%%)

is unexpected at this time.

I passed the following statement

findstr %EndPageSetup(.+)(%%[((LastPage)|(Page: \d+))]%%) g:\files\WDDEF07.tmp

WDDE07.tmp is a postscript file.

the file i used is https://rapidshare.com/files/2509921619/WDDEF07.tmp

please help me to solve this error.


Solution

  • I you are running this from a command line or a batch file, the command shell is interpreting | as a pipe, not an alternation like we regexers are used to. In the command shell, | means to take the standard output of the previous command and 'pipe' it into the next command's standard input, like this:

    C:\>dir |find ".txt"
    

    I found no reference to alternations in the documentation. If you can find a way to do what you want without alternations, you might try the findstr /G:file option (where file contains the regular expression). This way, you won't have to fight the command shell's special characters.