title: Writing a simple regex class only gives empty results
body: <p>I'm fairly new to classes in java so I just thought I'd have a go at writing a simple regex class. And I failed.</p>
  
  <p>Here is the class</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.regex.Matcher;
  import java.util.regex.Pattern;
  
  public class HRM_SwallowTableExtractor {
      String x;
      String pattern;
      ArrayList&lt;String&gt; myArray = new ArrayList&lt;String&gt;();
  
      public HRM_SwallowTableExtractor(String x,String pattern) {
          x=this.x;
          pattern=this.pattern;
      }
  
      public ArrayList&lt;String&gt; SwallwTabExtract(String x,String pattern) {
          Pattern pat = Pattern.compile(pattern);
          Matcher matcher_pattern = pat.matcher(x);
  
          while (matcher_pattern.find()) {
              String p=matcher_pattern.group(1).trim();
              String [] arr=p.split("\\s");
              for (int i=0;i&lt;arr.length;i++){
                  myArray.add(arr[i]);
              }
          }
          return myArray;
      }
  }
  </code></pre>
  
  <p>and here in the main class:</p>
  
  <pre><code>String UESRecovTime_pattern="(UES_recovery_time_\\(msec\\).*)";
  HRM_SwallowTableExtractor swallTabExtract=new HRM_SwallowTableExtractor(stuff,UESRecovTime_pattern);
  </code></pre>
  
  <p>However when I run this I only get an empty array returned. I think the problem is that the pattern is not being found (yes it is in the text body). In turn I think this has something to do with how the main text is being brought into the instantiated class (as String x) or with how the Pattern is instantiated. I don't know how to figure this one out. I haven't put the text up that I am using but happy to if its needed.</p>