title: Batch File If Statement Using Regex
body: <p>I have a batch file that first checks an outside file to see the source branch for the build then runs an <code>if</code> <code>else if</code> statement that runs regex to match the source branch which then determines where the build will deploy:</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion
  set SEPARATOR=/
  set filecontent=
  for /f "usebackqdelims=" %%a in ("BuildBranch.txt") do (
    set currentline=%%a
    set filecontent=!filecontent!%SEPARATOR%!currentline!
  )
  
  echo %filecontent%
  
  If NOT "%filecontent%"=="develop(.*)" (
      echo Deploying to dev DEVELOP
  ) else If NOT "%filecontent%"=="^.feature(.*)" (
      echo Deploying to dev FEATURE
  ) else If NOT "%filecontent%"=="master(.*)" (
      echo Deploying to integration MASTER
  ) else If NOT "%filecontent%"=="^.hotfix(.*)" (
      echo Deploying to integration HOTFIX
  )
  
  pause
  </code></pre>
  
  <p>I have run each of the regex's through the regex101 site but there may still be issues with them. My main issue is that ever time I run my batch file it only runs the first of the <code>If statements</code>. The variable <code>%filecontent%</code> is <code>feature/MyNewFeature</code> so it should see that it doesn't match the first if statement and go on to the second statement. I don't know if this is an issue with my regex or my <code>if statements</code>. </p>