title: How to get full sentence using regex in java
body: <p>As of now, I'm parsing PDF using <a href="https://pdfbox.apache.org/" rel="nofollow">PDFBox</a> later I will be parsing other documents (.docx/.doc). Using PDFBox, I'm getting all file content into one string. Now, I wanted to get complete sentence wherever a user define words matches. </p>
  
  <p>For example:</p>
  
  <pre><code>... some text here..
  Raman took more than 12 year to complete his schooling and now he
  is pursuing higher study.
  Relational Database. 
  ... some text here ..
  </code></pre>
  
  <p>If user gives the input <code>year</code>, then it should return whole sentence. </p>
  
  <p><strong>Expected Output:</strong></p>
  
  <pre><code>Raman took more than 12 year to complete his schooling and now he
      is pursuing higher study.
  </code></pre>
  
  <p>I'm trying below code, but it showing nothing. Can anyone correct this</p>
  
  <pre><code> Pattern pattern = Pattern.compile("[\\w|\\W]*+[YEAR]+[\\w]*+.");
  </code></pre>
  
  <p>Also, If I have to include multiple words to match as <code>OR</code> condition, then what should I make change in my regex ? </p>
  
  <p><strong>Please note all words are in uppercase.</strong></p>