title: grep substring between two delimiters
body: <p>I have a lot of <code>bash</code> scripts that use <code>perl</code> expressions within <code>grep</code> in order to extract a substring between two delimiters. Example:</p>
  
  <pre><code>echo BeginMiddleEnd | grep -oP '(?&lt;=Begin).*(?=End)'
  </code></pre>
  
  <p>The problem is, when I ported these scripts to a platform running <code>busybox</code>, 'integrated' <code>grep</code> does not recognize -P switch. Is there a clean way to do this using <code>grep</code> and <code>regular expressions</code>?</p>
  
  <p>Edit:
  There is no <code>perl</code>, <code>sed</code> or <code>awk</code> on that platform. It's a lightweight <code>linux</code>.</p>