title: How to use a regex for the field separator in AWK?
body: <p>I read <a href="https://stackoverflow.com/a/22544989/2909897">another answer</a> that show how one can set the field separator using the <code>-F</code> flag:</p>
  
  <pre><code>awk -F 'INFORMATION DATA ' '{print $2}' t
  </code></pre>
  
  <p>Now I'm curious how I can use a regex for the field separator. My attempt can be seen below:</p>
  
  <pre><code>$ echo "1 2 foo\n2 3 bar\n42 2 baz"
  1 2 foo
  2 3 bar
  42 2 baz
  $ echo "1 2 foo\n2 3 bar\n42 2 baz" | awk -F '\d+ \d+ ' '{ print $2 }'
  # 3 blank lines
  </code></pre>
  
  <p>I was expecting to get the following output:</p>
  
  <pre><code>foo
  bar
  baz 
  </code></pre>
  
  <p>This is because my regex <code>\d+ \d+</code> matches "the first 2 numbers separated by a space, followed by a space". But I'm printing the second record. As shown on <a href="http://rubular.com/r/jpSVUvCGHr" rel="nofollow noreferrer">rubular</a>:</p>
  
  <p><a href="https://i.stack.imgur.com/90LIE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/90LIE.png" alt="enter image description here"></a></p>
  
  <ul>
  <li>How do I use a regex as the awk field separator?</li>
  </ul>