title: Find a word in a line based on next word
body: <p>I have a file and here is a portion of of the file. The common word in all lines is PIC here and I am able to find out the index of PIC.  I am trying to extract the description for each line. Here how can I extract the word before the word PIC? </p>
  
  <pre><code>          15 EXTR-SITE                                 PIC X.
          05 EXTR-DBA                                    PIC X.
  TE0305*     05 EXTR-BRANCH                         PIC X(05).
  TE0305*     05 EXTR-NUMBER                         PIC X(06).
  TE0305      05 FILLER                                  PIC X(11).
  CW0104        10 EXTR-TEXT6                       PIC X(67).
  CW0104        10 EXTR-TEXT7                       PIC X(67).
  CW0104*     05 FILLER                                  PIC X(567).
  </code></pre>
  
  <p>I have to get result like below</p>
  
  <pre><code>EXTR-SITE 
  EXTR-DBA
  EXTR-NUMBER
  -------
  FILLER
  </code></pre>
  
  <p>Is there any expression I can use to find the word before 'PIC'?</p>
  
  <p>Here is my code to get lines that contain 'PIC':</p>
  
  <pre><code>int wordStartIndex = line.indexOf("PIC");
  int wordEndIndex = line.indexOf(".");
  if ((wordStartIndex &gt; -1) &amp;&amp; (wordEndIndex &gt;= wordStartIndex)) {
  System.out.println(line); }
  </code></pre>