title: Split UK postcode into two main parts using java
body: <p>This regular expression for validating postcodes works perfect</p>
  
  <pre><code>^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) {0,1}[0-9][A-Za-z]{2})$
  </code></pre>
  
  <p>but I want to split the postcodes to retrieve the individual parts of the postcode using java.</p>
  
  <p>How can this be done in java?</p>