title: Extract from formatted string using Java
body: <p>I have strings of the following formats:</p>
  
  <ul>
  <li>[(xx)(KEY1)some text]</li>
  <li>Some text [(yy)(KEY1)some text]</li>
  <li>Some text [(qq)(KEY1)some text] More text here [(zz)(KEY2)some text] etc.</li>
  </ul>
  
  <p>Basically the form <strong>[(xx)(KEYX)some text]</strong> appears once or multiple times in a string mingled with other characters.</p>
  
  <p>In the above format, the key is <em>KEYX</em> and the value is <em>some text</em>.</p>
  
  <p>I would like to extract all the key value pairs from any string containing any number of such formats.</p>
  
  <p>I tried using straight parsing using substring etc., but that does not seem a clean solution. Is it possible to do it better using regex or any other technique that Java provides?</p>