title: Get results with whitespace in lucene
body: <p>I'm trying to get results with whitespace using Lucene <code>RegexpQuery</code>.
  Try ever possible search regex text like;</p>
  <pre><code>[a-z]{4}\s[a-z]{5}
  [a-z]{4}( )[a-z]{5}
  [a-z]{4}(\s)[a-z]{5}
  </code></pre>
  <p>I use (now) basic and use standard methods like;</p>
  <pre><code>...
  IndexWriter writer = createWriter(storePath);
  Document docu1 = indexDoc(writer, catchText, Files.getLastModifiedTime(docDir).toMillis(), value.getUniqueId());
  documents.add(docu1);
  ...
  writer.addDocuments(documents);
  writer.commit();
  ...
  IndexReader reader = DirectoryReader.open(writer);
  IndexSearcher searcher = new IndexSearcher(reader);
  ...
  Query q1 = new RegexpQuery(new Term(&quot;contents&quot;, var.getRuleText()), RegExp.ALL);
  ...
  Document docX = reader.document(idX);
  String textX = docX.get(&quot;contents&quot;);
  TokenStream tokenStream = TokenSources.getTokenStream(&quot;contents&quot;, reader.getTermVectors(idX),textX,new StandardAnalyzer(), -1);
  OffsetAttribute offsetAtt = (OffsetAttribute)tokenStream.addAttribute(OffsetAttribute.class);
  </code></pre>
  <p>How can I search with regex containing whitespace using <code>RegexpQuery</code>? If <code>RegexpQuery</code> can't be used is there any other suggested approach?</p>
  <p>Search Text Example:</p>
  <pre><code>Lorem ipsum test dolor sit amet.
  </code></pre>
  <p>Must Result:</p>
  <pre><code>test dolor
  </code></pre>