title: Java Regex to extract specific words
body: <p>I am trying to extract all the presence of 'and', 'a', 'the', 'an','&amp; amp ;' from a block of text along with all the presence of digits.</p>
  
  <p>I tried to create different regex for that purpose but fail to get the accurate result.</p>
  
  <p>All the digits are extracted fine but I am unable to fetch all the aforementioned strings through regex.</p>
  
  <p>My basic regex was </p>
  
  <pre><code> Pattern p = Pattern.compile("^[0-9]");
  </code></pre>
  
  <p>then I tried different combinations like </p>
  
  <pre><code> Pattern p = Pattern.compile("^[0-9](&amp;amp;)");
   Pattern p = Pattern.compile("^[0-9]+[&amp;amp;]");
  </code></pre>
  
  <p>to get aforementioned strings but of no use.</p>
  
  <p><strong>Example of the text</strong>: </p>
  
  <pre><code>System requirements: iOS 6.0 and Android (varies) &amp;amp;
  Version used in this guide: 2.2.4 (iPhone), 13.1.2 (Android)
  </code></pre>
  
  <p><strong>Expected Result</strong> </p>
  
  <pre><code> 6.0,and,&amp;amp;,2.2.4,13.1.2
  </code></pre>