6

I want to specify whitespace after a certain word (SetupAX) that I am searching in a file.

I am trying the findstr command this way -

   findstr /n /r "SetupAX[ \r\n\t]" XYZ.frm

However, this doesn't work. If I don't put the whitespace, I get results like -

   findstr /n /r "SetupAX" XYZ.frm

   158: If Filled() Then Call SetupAXForB
   170: SetupAXForC
   196: SetupAX          //<-- correct
   242: Call SetupAX     //<-- correct
   276: Call SetupAXN
   ...

How do I get around this? I only want instances of "SetupAX" and not "SetupAX...". Thanks.

CodeBlue
  • 14,631
  • 33
  • 94
  • 132

3 Answers3

1

You need to use the /c option. Like this:

findstr /M /S /I /c:"some sentence with spaces" *.*
Fotios Basagiannis
  • 1,432
  • 13
  • 14
1

How about using the end of word matching expression?

findstr /n /r "SetupAX\>" XYZ.frm
wallyk
  • 56,922
  • 16
  • 83
  • 148
0

findstr -n -r -c:"SetupAX[ \r\n\t]" works only partially. It doesn't match neither \n nor \r.

With normal regular expressions it could be written as SetupAX[ ]|$, but findstr doesnt' support alternatives (|). So you need to search twice: 'SetupAX " and "SetupAX$"

kirilloid
  • 14,011
  • 6
  • 38
  • 52
  • Ok, `\r\n` actually doesn't work. It is only possible to match the end of line with `$`, but it doesn't work inside `[]` – kirilloid Mar 21 '12 at 19:15