title: How to match arbitrary characters inside [] groups?
body: <p>I am looking for all combinations for <code>foo</code> and <code>bar</code> no matter which order, which could run across multiple lines (in practice, no longer than 5 lines). Here is a test file:</p>
  
  <pre><code>$ cat test
  foo
  a
    bar
  b
  1 foo 2 bar 3
  1 foo2bar 3
  
  
  
  
  bar
  a
    foo
  b
  1 bar 2 foo 3
  1 bar2foo 3
  </code></pre>
  
  <p><strong>I am having trouble matching individual characters with newlines when using <code>pcregrep</code>.</strong> I can match all individual characters just fine:</p>
  
  <pre><code>$ pcregrep --color -Mi '(foo.*bar)?(bar.*foo)?' test
  test:1 foo 2 bar 3
  test:1 foo2bar 3
  test:1 bar 2 foo 3
  test:1 bar2foo 3
  $
  </code></pre>
  
  <p>However it can be seen that the multiline foo/bar combinations are not matched. Thus I try to match all characters <code>\.</code> and newlines <code>\n</code> but this is not returning any lines:</p>
  
  <pre><code>$ pcregrep --color -Mi '(foo[.\n]*bar)?(bar[.\n]*foo)?' *
  $
  </code></pre>
  
  <p>In fact, I cannot seem to match and single character with the <code>.</code> operator at all in a <code>[]</code> group:</p>
  
  <pre><code>$ pcregrep --color -Mi '(foo[.]*bar)?(bar[.]*foo)?' *
  $ pcregrep --color -Mi '(foo[\.]*bar)?(bar[\.]*foo)?' *
  $
  </code></pre>
  
  <p><strong>How can I put the <code>.</code> operator inside a <code>[]</code> group?</strong></p>