title: Regular expression to match exact substring at the beginning of string
body: <p>I have one substring to be matched exactly at the beginning of source string. </p>
  
  <pre><code>source_string = "This is mat. This is cat."
  
  substring1 = "This is"
  
  substring2  = "That is"
  
  source_string.match(/^(#{substring1}|#{substring2})$/)
  </code></pre>
  
  <p>This is what I tried it should work like this, if exact '<code>This is</code>' or '<code>That is</code>' is there at the beginning of string it should match, doesn't matter what is there after those substrings in <code>source_string</code>. My code is giving <code>nil</code> even if <code>'This is'</code> is present.</p>