title: Best way to split a string containing question marks and equals
body: <p>Having an issue where I have a java string:</p>
  
  <pre><code>String aString="name==p==?header=hello?aname=?????lname=lastname";
  </code></pre>
  
  <p>I need to split on question marks followed by equals.</p>
  
  <p>The result should be key/value pairs:</p>
  
  <pre><code>name = "=p=="
  header = "hello"
  aname = "????"
  lname = "lastname"
  </code></pre>
  
  <p>The problem is aname and lname become:</p>
  
  <pre><code>name = ""
  lname = "????lname=lastname"
  </code></pre>
  
  <p>My code simply splits by doing <code>aString.split("\\?",2)</code><br>
  which will return 2 strings.One contains a key/value pair and the second string contains 
  the rest of the string. If I find a question mark in the string, I recurse on the second string to further break it down.</p>
  
  <pre><code>private String split(String aString)
   {
      System.out.println("Split: " + aString);
      String[] vals = aString.split("\\?",2);
      System.out.println("  - Found: " + vals.length);
      for ( int c = 0;c&lt;vals.length;c++ )
         {
          System.out.println("  - "+ c + "| String: [" + vals[c] + "]" );
          if(vals[c].indexOf("?") &gt; 0 )
            {
              split(vals[c]);
             }
          }
      return ""; // For now return nothing...
   }
  </code></pre>
  
  <p>Any ideas how I could allow a name of ?<br>
  <strong>Disclaimer:</strong> Yes , My Regex skills are very low, so I don't know if this could be done via a regex expression.</p>