2

I have a string in a file like,

async.AsyncTranslationThread - processPart: Finished Processing job number: J215577 partID: 151269

any many more.

I want to return only that line which has substring Finished Processing job number

I wrote a findstr command with regex like

findstr /R "^.*Finished\sProcessing\sjob\snumber.*$" filename

I am getting nothing in return, what would be the change in regex to get the string with substring in it?

Laxmi Kadariya
  • 1,103
  • 1
  • 14
  • 34

1 Answers1

2

If you take a look at the documentation, findstr doesn't support most traditional regex features, such as \s, which you are using. It doesn't even support the + quantifier!

The following table lists the metacharacters that findstr accepts.

| Meta Character | Value
| .              | Wildcard: any character
| *              | Repeat: zero or more occurrences of the previous character or class
| ^              | Line position: beginning of the line
| $              | Line position: end of the line
| [class]        | Character class: any one character in a set
| [^class]       | Inverse class: any one character not in a set
| [x-y]          | Range: any characters within the specified range
| \x             | Escape: literal use of a metacharacter x
| \<string       | Word position: beginning of the word
| string\>       | Word position: end of the word

You can easily get away with this, and it'll still accept it if even there are multiple spaces or tabs:

findstr /c:"Finished Processing job number" filename

Furthermore, it seems that it's not even case sensitive by default

Addison
  • 7,322
  • 2
  • 39
  • 55