title: Using match to find substrings in strings with only bash
body: <p>Although I am almost sure this has been covered, I can't seem to find anything specific to this. As I continue my journey on learning bash I keep finding parts where I am baffled as to why things happen the way they do. </p>
  
  <p>Searching and replacing or just matching sub-strings in strings is most likely one of the first thing you do when writing scripts. But, trying to stick to one single language or set of tools is difficult to do in bash, as you are able to solve most problem in multiple ways. I am doing my best to stay as low level as possible with bash. I have run into a snag that I need someone to explain to me. </p>
  
  <p>Doing sub-string a search in bash with match gives me different results depending on the regular expression I use, and I am not sure why. </p>
  
  <pre><code>#!/bin/bash
  Stext="Hallo World"
  echo `expr "$Stext" : '^\(.[a-z]*\)'` # Hallo
  echo `expr "$Stext" : '.*World'`      # 11
  </code></pre>
  
  <p>Although both search for a word, <em>I think</em>, both don't return what they find. Why? </p>