title: Get the beginning of a string until a given char
body: <p>I know that is a simple question but I couldn't find the answer.</p>
  
  <p>I have this string: </p>
  
  <pre><code>"M1[r2][r3]"
  </code></pre>
  
  <p>I want to get only the <code>"M1"</code>, I'm looking for something like <code>strchr()</code>
  a function that get the string and a <code>char</code> to stop at.</p>