title: Is it possible to regex search text in a PDF or Word document using java?
body: <p>I am not asking any products recommendations </p>
  
  <p>I want to search text from a word document or pdf document using a regular expression with Java. Is it possible? How to do this?</p>
  
  <p>For example, the <code>PDF/DOC</code> look like this:</p>
  
  <pre>
  
  (54) About Keyboard                                     More Info
  
  Date: 29/02/2003                                     Printed: US
  Filed: 19/03/2005                                     Viewed: 5 times 
  
  </pre>
  
  <p>Now my aim is to run a regex-based search on this document using java.</p>
  
  <p>Initially, I tried text extraction but since these are unstructured and scattered I can't use the extracted text.</p>
  
  <p>For example, I want to do this:</p>
  
  <pre><code>File fl = new File ("sample.pdf");
  String res=  FindBYRegex ("(?s)\\(54\\)\\s*(.*?)\\s*(?=\\(\\d|$\\))");
  System.out.println (res);    
  </code></pre>
  
  <p>The output I want would be: <code>(54) About Keyboard</code></p>
  
  <p>How to achieve my objective? Which library help me to do this using Java?</p>