title: Using findstr with regular expressions to search sections of a string
body: <p>I have created code which loops through each line of <code>files.txt</code> and identifies if the file is <code>car</code>, <code>boat</code> or <code>neither</code> and stores this information into <code>SendType.txt</code>. This is accomplished by using the <code>findstr</code> command and searching through the list of <code>boat.txt</code> and <code>car.txt</code>. Essentially the way the code is designed, it will take the first line of <code>files.txt</code> and see if it can find the string in <code>car.txt</code> (if so <code>car</code> is output to <code>SendType.txt</code>) if not it will search for the string in <code>boat.txt</code> (if the string is found in <code>boat.txt</code>, <code>boat</code> is output to <code>SendType.txt</code>), and if the string is not found in either car.txt or <code>boat.txt</code>, then the text <code>neither</code> is output to <code>SendType.txt</code></p>
  
  <p>Right now the code searches for the entire string line. Each string is similar to <code>11111_2222-22_2010-09-09_10-24-20.zip</code> (<code>11111</code>=ID, <code>2222-22</code>=model, <code>2010-09-09</code>=date, <code>10-24-20</code>=transaction ID). </p>
  
  <p>I would like to replace my current findstr line, which searches the entire line, to search for the entire string EXCEPT the date portion. I have attached my code below for reference along with some examples of the files being input. Thanks in advance!</p>
  
  <pre><code>@echo off
  FOR /F %%a in (files.txt) do (
  findstr %%a car.txt
  if errorlevel 1 (
  findstr %%a boat.txt
      if errorlevel 1 (
      echo neither &gt;&gt;SendType.txt
  ) else (
      echo boat &gt;&gt;SendType.txt
  )
  ) else (
      echo car &gt;&gt;SendType.txt
  )
  )
  </code></pre>
  
  <hr>
  
  <pre><code>car.txt
  11111_2222-22_2010-09-09_10-24-20.zip
  11112_2222-11_2011-11-09_10-24-25.zip
  </code></pre>
  
  <hr>
  
  <pre><code>boat.txt
  11122_1111-22_2012-04-09_11-29-56.zip
  11144_3333-11_2011-12-22_06-29-66.zip
  </code></pre>
  
  <hr>
  
  <pre><code>files.txt
  11122_1111-22_2000-01-01_11-29-56.zip
  11144_3333-11_2000-01-01_06-29-66.zip
  11155_1212-12_2000-01-01_11-19-69.zip
  11111_2222-22_2000-01-01_10-24-20.zip
  11112_2222-11_2000-01-01_10-24-25.zip
  12345_2233-12_2000-01-01_07-27-44.zip
  </code></pre>
  
  <hr>
  
  <p>DESIRED OUTPUT:</p>
  
  <pre><code>SendType.txt
  boat
  boat
  neither
  car
  car
  neither
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE 10/15 3:00 PM</strong>
  The current approach using dbenham's code and the parsing technique is as follows:</p>
  
  <pre><code>@echo off    
  &gt;SendType.txt (  
  for /f "tokens=1,2,3,4 delims=_" %%a in (filenames.txt) do (    
  findstr /c:"%%a_%%b_%%d" sneakernet.txt &gt;nul &amp;&amp; (echo sneakernet) || (      
  findstr /c:"%%a_%%b_%%d" devmed.txt &gt;nul &amp;&amp; (echo devmed) || echo tanto   
         ) 
      )
  )
  </code></pre>