title: Expect regex number pattern
body: <p>I'm having this poblem with a expect script. I want to capture when the output of a command is "0" and distinguish from other numbers or chains like "000" or "100"</p>
  
  <p>my code is:</p>
  
  <pre><code>#!/usr/bin/expect -f
  set timeout 3
  spawn bash send "echo 0\n" 
  expect {
  -regexp {^0$} { send_user "\nzero\n" }  
  -re {\d+} { send_user "\number\n"}
  }
  send "exit\n"
  </code></pre>
  
  <p>I have the follwing response:</p>
  
  <pre><code>spawn bash
  echo 0
  
  number
  </code></pre>
  
  <p>But the following regex don't work:</p>
  
  <pre><code>-regexp {^0$} { send_user "\nzero\n" }
  </code></pre>
  
  <p>if I change it to:</p>
  
  <pre><code>-regexp {0} { send_user "\nzero\n" }
  </code></pre>
  
  <p>works, but it also capture "00" "10" "1000" etc.</p>
  
  <pre><code>send "echo 100\n"
  expect {
      -regexp {0} { send_user "\nzero\n" }
      -re {\d+} { send_user "\nnumber\n"}
  }
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>spawn bash
  echo 10
  
  zero
  </code></pre>
  
  <p>I don't know what I'm doing wrong and I didn't found any from help on google. I also searched for similar problems resolved here I couldn't make any of it work on my code.</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>I tried the proposed fix code:</p>
  
  <pre><code>#!/usr/bin/expect -f
  set timeout 3
  spawn bash
  send "echo 0\n"
  expect {
      -regexp {\b0\b} { send_user "\nzero\n" }
      -re {\d+} { send_user "\nnumber\n"}
  }
  send "exit\n"
  </code></pre>
  
  <p>But I still having this response:</p>
  
  <pre><code>spawn bash
  echo 0
  
  number
  </code></pre>
  
  <p><strong>Update 2</strong></p>
  
  <p>I also tried this line:</p>
  
  <pre><code> -regexp {"^0\n$"} { send_user "\nzero\n" }
  </code></pre>
  
  <p>But I still having the same results.</p>
  
  <p>Thanks in advance</p>