title: Substring help in batch file
body: <p>How do I extract everything between incno and the space ie12345678 in the example batch below and put it into a incno variable?</p>
  
  <pre><code>@echo off  
  Set mystring=test incno12345678 wo5555 locFred Street   
  Echo "my string=%mystring%"   
  Echo incno   
  Echo wo    
  Echo loc  
  </code></pre>
  
  <p>The incno can be 8 to 11 digits long but will always be between incno and a space in the string</p>
  
  <p>I am now having trouble assigning the %%d variable to the mystring variable now it is in a for loop. Can anyone help me with this? See Below.</p>
  
  <pre><code>@echo off
  SETLOCAL enableDelayedExpansion
  color 0B
  For /d %%d in ("C:\Users\%Username%\LocalData\*") do (
  Echo "Folder = %%d"
  Set mystring=%%d
  echo "MyString = %mystring%"
  pause
  REM delete until (including) "incno":
  set mystring=%mystring:*incno=%
  echo %mystring%
  REM delete starting with (including) " ":
  set mystring=%mystring: =&amp;rem %
  echo "Incident Number = %mystring%"
  pause
  )
  </code></pre>